public async Task Should_Save_Municipality(int id, string name, string pointOfContact, string email, string modifiedBy, string createdBy, bool isActive, string nameComparer, int expectedCount, int expectedId) { //Arrange var addressModel = new Domains.Address { Id = id, Address1 = "123 Straight Way", City = "Arlington", State = 17, Zip = "76012" }; var model = new Municipalities { Id = id, Name = name, PointOfContact = pointOfContact, Email = email, AddressId = 1, Address = addressModel }; var countBefore = UsingDbContext(context => { return(context.Municipalities.Count(x => x.IsActive)); }); //Act if (id != 0) { UsingDbContext(context => { var originalData = context.Municipalities.FirstOrDefault(x => x.Id == id); originalData.ShouldNotBeNull(); originalData.Name.ShouldBe(nameComparer); }); } _municipalityService.SaveMunicipality(model); var count = UsingDbContext(context => { return(context.Municipalities.Count()); }); var municipalities = UsingDbContext(context => { return(context.Municipalities.FirstOrDefault(x => x.Id == expectedId)); }); count.ShouldBe(expectedCount); municipalities.ShouldNotBeNull(); municipalities.Name.ShouldBe(name); }
public Domains.Municipalities ConvertToMunicipalities() { var address = new Domains.Address { Id = AddressId, Address1 = MunicipalAddress.Address1, Address2 = MunicipalAddress.Address2, Address3 = MunicipalAddress.Address3, City = MunicipalAddress.City, State = MunicipalAddress.State, Zip = MunicipalAddress.Zip, Phone = MunicipalAddress.Phone, Fax = MunicipalAddress.Fax, //Address1 = Address1, //Address2 = Address2, //Address3 = Address3, //City = City, //State = State, //Zip = Zip, //Phone = Phone, //Fax = Fax, CreationTime = CreationTime, CreatorUserId = CreatorUserId, DeleterUserId = DeleterUserId, DeletionTime = DeletionTime, LastModificationTime = LastModificationTime, LastModifierUserId = LastModifierUserId }; var municipalities = new Domains.Municipalities { Id = Id, Name = Name, IsActive = IsActive, PointOfContact = PointOfContact, Email = Email, AddressId = AddressId, CreatorUserId = CreatorUserId, CreationTime = CreationTime, DeleterUserId = DeleterUserId, DeletionTime = DeletionTime, LastModificationTime = LastModificationTime, LastModifierUserId = LastModifierUserId, Address = address }; return(municipalities); }