public void GivenASerializer_WhenDeserializingIsOn_ThenWeGetSettings() { var serializer = new StrategySettingsSerializer(); var json = "{ \"IsOn\":true}"; var strategy = serializer.Deserialize(StrategyNames.IsOn, json); strategy.Should().BeOfType <IsOnStrategy>(); }
public void GivenASerializer_WhenDeserializingIsLowerThan_ThenWeGetSettings() { var serializer = new StrategySettingsSerializer(); var json = "{ \"Value\": 5 }"; var strategy = serializer.Deserialize(StrategyNames.IsLowerThan, json); strategy.Should().BeOfType <IsLowerThanStrategy>(); var expectedStrategy = strategy as IsLowerThanStrategy; expectedStrategy.Settings.Value.Should().Be(5); }
public void GivenASerializer_WhenDeserializingIsAfter_ThenWeGetSettings() { var clock = this.GivenClock().UtcNow; var dateInString = clock.ToString("O"); var serializer = new StrategySettingsSerializer(); var json = "{ \"Value\": \"" + dateInString + "\" }"; var strategy = serializer.Deserialize(StrategyNames.IsAfter, json); strategy.Should().BeOfType <IsAfterStrategy>(); var expectedStrategy = strategy as IsAfterStrategy; expectedStrategy.Settings.Value.Should().Be(clock); }
public void GivenASerializer_WhenDeserializingIsInList_ThenWeGetSettings() { var serializer = new StrategySettingsSerializer(); var json = "{ \"ListName\" : \"patate\", \"Items\": [\"a\"] }"; var strategy = serializer.Deserialize(StrategyNames.IsInList, json); strategy.Should().BeOfType <IsInListStrategy>(); var expectedStrategy = strategy as IsInListStrategy; expectedStrategy.Settings.ListName.Should().Be("patate"); expectedStrategy.Settings.Items.Should().BeEquivalentTo(new List <string> { "a" }); }