openmu/tests/MUnique.OpenMU.AttributeSystem.Tests/SimpleElementTests.cs

61 lines
1.9 KiB
C#
Raw Permalink Normal View History

2017-11-23 07:10:40 +01:00
// <copyright file="SimpleElementTests.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>
namespace MUnique.OpenMU.AttributeSystem.Tests;
2017-11-23 07:10:40 +01:00
/// <summary>
/// Tests for the <see cref="SimpleElement"/>.
/// </summary>
[TestFixture]
public class SimpleElementTests
{
2017-11-23 07:10:40 +01:00
/// <summary>
/// Tests if the value is 0 after creation.
2017-11-23 07:10:40 +01:00
/// </summary>
[Test]
public void ValueIsNullAfterCreation()
2017-11-23 07:10:40 +01:00
{
var element = new SimpleElement();
Assert.That(element.Value, Is.EqualTo(0));
}
2017-11-23 07:10:40 +01:00
/// <summary>
/// Tests if the value returns the same as what has been set before.
/// </summary>
[Test]
public void ValueIsSet()
{
const int elementValue = 4711;
var element = new SimpleElement { Value = elementValue };
Assert.That(element.Value, Is.EqualTo(elementValue));
}
2017-11-23 07:10:40 +01:00
/// <summary>
/// Tests if the <see cref="SimpleElement.ValueChanged"/> is called when the <see cref="SimpleElement.Value"/> has been changed.
/// </summary>
[Test]
public void ValueChangedEventWhenValueChanges()
{
var element = new SimpleElement();
bool eventCalled = false;
element.ValueChanged += (sender, e) => eventCalled = true;
element.Value = 6;
2017-11-23 07:10:40 +01:00
Assert.That(eventCalled, Is.True);
}
2017-11-23 07:10:40 +01:00
/// <summary>
/// Tests if the <see cref="SimpleElement.ValueChanged"/> is called when the <see cref="SimpleElement.AggregateType"/> has been changed.
/// </summary>
[Test]
public void ValueChangedEventWhenAggregateTypeChanges()
{
var element = new SimpleElement { Value = 0 };
bool eventCalled = false;
element.ValueChanged += (sender, e) => eventCalled = true;
element.AggregateType = AggregateType.AddFinal;
2017-11-23 07:10:40 +01:00
Assert.That(eventCalled, Is.True);
2017-11-23 07:10:40 +01:00
}
}