public void Can_Map_Guid_Values_To_Guid_Properties() { // Arrange const int id = 1; const string firstName = "Bob"; const string lastName = "Smith"; Guid uniqueId = Guid.NewGuid(); dynamic dynamicPerson = new ExpandoObject(); dynamicPerson.Id = id; dynamicPerson.FirstName = firstName; dynamicPerson.LastName = lastName; dynamicPerson.UniqueId = uniqueId; // Act PersonWithProperties customer = AutoMapper.MapDynamic <PersonWithProperties>(dynamicPerson); // Assert Assert.NotNull(customer); Assert.That(customer.Id == id); Assert.That(customer.FirstName == firstName); Assert.That(customer.LastName == lastName); Assert.That(customer.UniqueId == uniqueId); }
public void Can_Map_Null_Values_To_Guid_Properties() { // Arrange const int id = 1; const string firstName = "Bob"; const string lastName = "Smith"; Guid uniqueId = Guid.NewGuid(); Guid? aNullableUniqueId = null; dynamic dynamicPerson = new ExpandoObject(); dynamicPerson.Id = id; dynamicPerson.FirstName = firstName; dynamicPerson.LastName = lastName; dynamicPerson.UniqueId = uniqueId.ToString(); dynamicPerson.ANullableUniqueId = aNullableUniqueId; // This is what we are testing // Act PersonWithProperties customer = AutoMapper.MapDynamic <PersonWithProperties>(dynamicPerson); // Assert Assert.NotNull(customer); Assert.That(customer.Id == id); Assert.That(customer.FirstName == firstName); Assert.That(customer.LastName == lastName); Assert.That(Equals(customer.UniqueId, uniqueId)); Assert.That(customer.ANullableUniqueId == aNullableUniqueId); // This is what we are testing }
public void Can_Map_Null_Values_To_Nullable_Enum_Properties() { // Arrange const int id = 1; const string firstName = "Jimbo"; const string lastName = "Smith"; const Gender gender = Gender.Male; MaritalStatus?maritalStatus = null; dynamic person = new ExpandoObject(); person.Id = id; person.FirstName = firstName; person.LastName = lastName; person.Gender = gender; person.MaritalStatus = maritalStatus; // Act PersonWithProperties customer = AutoMapper.MapDynamic <PersonWithProperties>(person); // Assert Assert.NotNull(customer); Assert.That(customer.Id == id); Assert.That(customer.FirstName == firstName); Assert.That(customer.LastName == lastName); Assert.That(customer.Gender == gender); Assert.That(customer.MaritalStatus == maritalStatus); }
public void Can_Map_DateTime_Values_To_Nullable_DateTime_Properties() { // Arrange const int id = 1; const string firstName = "Bob"; const string lastName = "Smith"; DateTime startDate = DateTime.Now.AddDays(-2); DateTime endDate = DateTime.Now; // This is what we are testing dynamic dynamicPerson = new ExpandoObject(); dynamicPerson.Id = id; dynamicPerson.FirstName = firstName; dynamicPerson.LastName = lastName; dynamicPerson.StartDate = startDate; dynamicPerson.EndDate = endDate; // Act PersonWithProperties customer = Slapper.AutoMapper.MapDynamic <PersonWithProperties>(dynamicPerson); // Assert Assert.NotNull(customer); Assert.That(customer.Id == id); Assert.That(customer.FirstName == firstName); Assert.That(customer.LastName == lastName); Assert.That(customer.StartDate == startDate); Assert.That(customer.EndDate == endDate); // This is what we are testing }
public void data_properties_are_used() { var template = "Name: " + DocXTemplateEngine.TOKEN_START + "Name" + DocXTemplateEngine.TOKEN_END + ", Age: " + DocXTemplateEngine.TOKEN_START + "Age" + DocXTemplateEngine.TOKEN_END; var data = new PersonWithProperties { Name = "Sam", Age = 29 }; var result = DocXTemplateEngine.ParseTemplate(template, data); result.ShouldBe("Name: Sam, Age: 29"); }
public void data_properties_are_used() { var template = "Name: " + DocXTemplateEngine.TOKEN_START + "Name" + DocXTemplateEngine.TOKEN_END + ", Age: " + DocXTemplateEngine.TOKEN_START + "Age" + DocXTemplateEngine.TOKEN_END; var data = new PersonWithProperties { Name = "Sam", Age = 29 }; var result = DocXTemplateEngine.ParseTemplate(template, data); result.ShouldBe("Name: Sam, Age: 29"); }