public void ApplyValues_Failed() { Random random = new Random(); String serilzedIdContent = random.GetAlphanumericString(); string serilizedIncludeChildrenValue = random.GetAlphanumericString(); IEnumerable <Guid> expectedAddress = random.NextGuids(); Mock <ISerializer> serliazerMock = new Mock <ISerializer>(); serliazerMock.Setup(x => x.Deserialze <IEnumerable <Guid> >(serilzedIdContent)).Returns(expectedAddress).Verifiable(); serliazerMock.Setup(x => x.Deserialze <Boolean>(serilizedIncludeChildrenValue)).Returns(true).Verifiable(); var condition = new DHCPv6ScopeIdNotificationCondition(GetRootScope(), serliazerMock.Object, Mock.Of <ILogger <DHCPv6ScopeIdNotificationCondition> >()); Dictionary <string, string> propertiesAndValues = new Dictionary <String, String> { { "IncludesChildren", serilizedIncludeChildrenValue }, { "ScopeIds2", serilzedIdContent }, }; Boolean applyResult = condition.ApplyValues(propertiesAndValues); Assert.False(applyResult); }
private DHCPv6ScopeIdNotificationCondition GetCondition(Random random, Boolean includeChildren, IEnumerable <Guid> scopeIds, DHCPv6RootScope rootScope = null) { String serilzedIdContent = random.GetAlphanumericString(); string serilizedIncludeChildrenValue = random.GetAlphanumericString(); Mock <ISerializer> serliazerMock = new Mock <ISerializer>(); serliazerMock.Setup(x => x.Deserialze <IEnumerable <Guid> >(serilzedIdContent)).Returns(scopeIds).Verifiable(); serliazerMock.Setup(x => x.Deserialze <Boolean>(serilizedIncludeChildrenValue)).Returns(includeChildren).Verifiable(); var condition = new DHCPv6ScopeIdNotificationCondition(rootScope ?? GetRootScope(), serliazerMock.Object, Mock.Of <ILogger <DHCPv6ScopeIdNotificationCondition> >()); Dictionary <string, string> propertiesAndValues = new Dictionary <String, String> { { "IncludesChildren", serilizedIncludeChildrenValue }, { "ScopeIds", serilzedIdContent }, }; condition.ApplyValues(propertiesAndValues); return(condition); }
public void ApplyValues_Cycle(Boolean includeChildren) { Random random = new Random(); String serilzedIdContent = random.GetAlphanumericString(); string serilizedIncludeChildrenValue = random.GetAlphanumericString(); IEnumerable <Guid> expectedAddress = random.NextGuids(); Mock <ISerializer> serliazerMock = new Mock <ISerializer>(); serliazerMock.Setup(x => x.Deserialze <IEnumerable <Guid> >(serilzedIdContent)).Returns(expectedAddress).Verifiable(); serliazerMock.Setup(x => x.Deserialze <Boolean>(serilizedIncludeChildrenValue)).Returns(includeChildren).Verifiable(); serliazerMock.Setup(x => x.Seralize(includeChildren)).Returns(serilizedIncludeChildrenValue).Verifiable(); serliazerMock.Setup(x => x.Seralize(expectedAddress)).Returns(serilzedIdContent).Verifiable(); var condition = new DHCPv6ScopeIdNotificationCondition(GetRootScope(), serliazerMock.Object, Mock.Of <ILogger <DHCPv6ScopeIdNotificationCondition> >()); Dictionary <string, string> propertiesAndValues = new Dictionary <String, String> { { "IncludesChildren", serilizedIncludeChildrenValue }, { "ScopeIds", serilzedIdContent }, }; Boolean applyResult = condition.ApplyValues(propertiesAndValues); Assert.True(applyResult); Assert.Equal(expectedAddress, condition.ScopeIds); Assert.Equal(includeChildren, condition.IncludesChildren); var createModel = condition.ToCreateModel(); Assert.Equal("DHCPv6ScopeIdNotificationCondition", createModel.Typename); Assert.Equal(propertiesAndValues, createModel.PropertiesAndValues, new NonStrictDictionaryComparer <String, String>()); }