public void ConvertToDictionaryParametersSucceeds() { // Arrange var sut = new ClassWithEnvironmentVariableAttributes() { StringPropertyWithAnnotation = "arbitrary-StringPropertyWithAnnotation", LongPropertyWithAnnotation = 42L, StringPropertyWithoutAnnotation = "arbitrary-StringPropertyWithoutAnnotation", LongPropertyWithoutAnnotation = 8L }; // Act var result = EnvironmentVariableConverter.Convert(sut); // Assert Assert.IsNotNull(result); if (!result.IsValid()) { var validationResults = result.GetValidationResults(); foreach (var validationResult in validationResults) { System.Diagnostics.Debug.WriteLine(validationResult.ErrorMessage); } } Assert.IsTrue(result.IsValid()); Assert.AreEqual(2, result.Keys.Count); Assert.IsTrue(result.ContainsKey(STRING_PROPERTY_WITH_ANNOTATION_ANNOTATION)); Assert.AreEqual("arbitrary-StringPropertyWithAnnotation", result[STRING_PROPERTY_WITH_ANNOTATION_ANNOTATION]); Assert.IsTrue(result.ContainsKey(LONG_PROPERTY_WITH_ANNOTATION_ANNOTATION)); Assert.AreEqual(42L, result[LONG_PROPERTY_WITH_ANNOTATION_ANNOTATION]); }
public void ExportTestSucceeds() { // Initialise Environment.SetEnvironmentVariable(STRING_PROPERTY_WITH_ANNOTATION_ANNOTATION, null); Environment.SetEnvironmentVariable(LONG_PROPERTY_WITH_ANNOTATION_ANNOTATION, null); string stringParam; var stringValue = "tralala"; string longParam; var longValue = 42L; stringParam = Environment.GetEnvironmentVariable(STRING_PROPERTY_WITH_ANNOTATION_ANNOTATION); Assert.IsNull(stringParam); longParam = Environment.GetEnvironmentVariable(LONG_PROPERTY_WITH_ANNOTATION_ANNOTATION); Assert.IsNull(longParam); var sut = new ClassWithEnvironmentVariableAttributes { StringPropertyWithAnnotation = stringValue, LongPropertyWithAnnotation = longValue, }; sut.Export(); stringParam = Environment.GetEnvironmentVariable(STRING_PROPERTY_WITH_ANNOTATION_ANNOTATION); Assert.AreEqual(stringValue, stringParam); longParam = Environment.GetEnvironmentVariable(LONG_PROPERTY_WITH_ANNOTATION_ANNOTATION); Assert.AreEqual(longValue.ToString(), longParam); // Cleanup Environment.SetEnvironmentVariable(STRING_PROPERTY_WITH_ANNOTATION_ANNOTATION, null); Environment.SetEnvironmentVariable(LONG_PROPERTY_WITH_ANNOTATION_ANNOTATION, null); stringParam = Environment.GetEnvironmentVariable(STRING_PROPERTY_WITH_ANNOTATION_ANNOTATION); Assert.IsNull(stringParam); longParam = Environment.GetEnvironmentVariable(LONG_PROPERTY_WITH_ANNOTATION_ANNOTATION); Assert.IsNull(longParam); }
public void ImportTestSucceeds() { // Initialise System.Environment.SetEnvironmentVariable(STRING_PROPERTY_WITH_ANNOTATION_ANNOTATION, null); System.Environment.SetEnvironmentVariable(LONG_PROPERTY_WITH_ANNOTATION_ANNOTATION, null); string stringParam; var stringValue = "tralala"; string longParam; var longValue = 42L; stringParam = System.Environment.GetEnvironmentVariable(STRING_PROPERTY_WITH_ANNOTATION_ANNOTATION); Assert.IsNull(stringParam); longParam = System.Environment.GetEnvironmentVariable(LONG_PROPERTY_WITH_ANNOTATION_ANNOTATION); Assert.IsNull(longParam); System.Environment.SetEnvironmentVariable(STRING_PROPERTY_WITH_ANNOTATION_ANNOTATION, stringValue); System.Environment.SetEnvironmentVariable(LONG_PROPERTY_WITH_ANNOTATION_ANNOTATION, longValue.ToString()); var sut = new ClassWithEnvironmentVariableAttributes(); EnvironmentVariableConverter.Import(sut); Assert.AreEqual(longValue, sut.LongPropertyWithAnnotation); Assert.AreEqual(stringValue, sut.StringPropertyWithAnnotation); Assert.AreEqual(0, sut.LongPropertyWithoutAnnotation); Assert.IsNull(sut.StringPropertyWithoutAnnotation); // Cleanup System.Environment.SetEnvironmentVariable(STRING_PROPERTY_WITH_ANNOTATION_ANNOTATION, null); System.Environment.SetEnvironmentVariable(LONG_PROPERTY_WITH_ANNOTATION_ANNOTATION, null); stringParam = System.Environment.GetEnvironmentVariable(STRING_PROPERTY_WITH_ANNOTATION_ANNOTATION); Assert.IsNull(stringParam); longParam = System.Environment.GetEnvironmentVariable(LONG_PROPERTY_WITH_ANNOTATION_ANNOTATION); Assert.IsNull(longParam); }