public void SerializeEnumValueTest() { SampleClass sampleEntity = new SampleClass { Description = "SerializeTest", EnumVal = SampleEnum.FirstValue }; string expectedJsonData = "{\"description\":\"SerializeTest\",\"enumVal\":\"FirstValue\"}"; string actualJsonData = jsonSerializer.Serialize <SampleClass>(sampleEntity); Assert.AreEqual(expectedJsonData, actualJsonData); }
public void DeserializeEnumValueTest() { string jsonData = "{\"description\":\"DeserializeTest\",\"enumVal\":\"SecondValue\"}"; SampleClass expectedSampleEntity = new SampleClass { Description = "DeserializeTest", EnumVal = SampleEnum.SecondValue }; SampleClass actualSampleEntity = jsonSerializer.Deserialize <SampleClass>(jsonData); Assert.AreEqual(expectedSampleEntity.Description, actualSampleEntity.Description); Assert.AreEqual(expectedSampleEntity.EnumVal, actualSampleEntity.EnumVal); }
public void PropertyGetterRequiresNonNullReturnValue() { var sample = new SampleClass(); Assert.Throws <InvalidOperationException>(() => Console.WriteLine(sample.NonNullProperty)); }
public void PropertySetterRequiresNonNullArgument() { var sample = new SampleClass(); var exception = Assert.Throws<ArgumentNullException>(() => {sample.NonNullProperty = null;}); Assert.Equal("value", exception.ParamName); }
public void DoesNotRequireNonNullForNonPublicMethod() { var sample = new SampleClass(); sample.PublicWrapperOfPrivateMethod(); }
public void RequiresNonNullOutValueNotEnforcedUponException() { var sample = new SampleClass(); string value; Assert.Throws<ContextMarshalException>(() => sample.MethodWithOutValueAndException(out value)); }
public void RequiresNonNullOutValue() { var sample = new SampleClass(); string value; Assert.Throws<InvalidOperationException>(() => sample.MethodWithOutValue(out value)); }
public void AllowsNullReturnValueWhenAttributeApplied() { var sample = new SampleClass(); sample.MethodAllowsNullReturnValue(); }
public void AllowsNullWhenAttributeApplied() { var sample = new SampleClass(); sample.SomeMethod("", null); }
public void RequiresNonNullArgument() { var sample = new SampleClass(); var exception = Assert.Throws<ArgumentNullException>(() => sample.SomeMethod(null, "")); Assert.Equal("nonNullArg", exception.ParamName); }
public void PropertyAllowsNullSetButNotGet() { var sample = new SampleClass {PropertyAllowsNullSetButDoesNotAllowNullGet = null}; Assert.Throws<InvalidOperationException>(() => Console.Write(sample.PropertyAllowsNullSetButDoesNotAllowNullGet)); }
public void PropertyAllowsNullGetButNotSet() { var sample = new SampleClass(); Assert.Null(sample.PropertyAllowsNullGetButDoesNotAllowNullSet); Assert.Throws<ArgumentNullException>(() => {sample.NonNullProperty = null;}); }
public void PropertyGetterRequiresNonNullReturnValue() { var sample = new SampleClass(); Assert.Throws<InvalidOperationException>(() => Console.WriteLine(sample.NonNullProperty)); }
public void TestSampleClass() { int result = new SampleClass().GetValue(); Assert.Equal(12, result); }
public void RequiresNonNullMethodReturnValue() { var sample = new SampleClass(); Assert.Throws <InvalidOperationException>(() => sample.MethodWithReturnValue(returnNull: true)); }
public void RequiresNonNullMethodReturnValue() { var sample = new SampleClass(); Assert.Throws<InvalidOperationException>(() => sample.MethodWithReturnValue(returnNull: true)); }