public void EveryPropertyShouldBeMappedProperly() { StatsModifierCollection smc1 = new StatsModifierCollection(); StatsModifierObject smo = 2d; foreach (var property1 in smc1.GetProperties()) { smc1 = 1; property1.SetValue(smc1, smo); ((StatsModifierObject)property1.GetValue(smc1)).Value.Should().Be(2d); foreach (var property2 in smc1.GetProperties().Where(x => x.Name != property1.Name)) { ((StatsModifierObject)property2.GetValue(smc1)).Value.Should().Be(1d); } } }
public void ShouldHaveFields() { StatsModifierCollection smo = new StatsModifierCollection(); var fields = smo.GetProperties(); fields.Should().NotBeNull(); fields.Length.Should().BeGreaterThan(0); fields.Where(x => x.Name == "AllowValueModification").Should().BeEmpty(); }
public void DisallowedModificationShouldThrowException() { StatsModifierCollection smc1 = new StatsModifierCollection(); smc1.AllowValueModification = false; foreach (var property in smc1.GetProperties()) { StatsModifierObject smo = 2d; Action action = () => property.SetValue(smc1, smo); action.ShouldThrow<Exception>().WithInnerException<DisallowedValueModificationException>().WithInnerMessage(property.Name); } }