public async Task GetAsync_SouldReturn_Null_IfPropertyDoNotExist() { var db = this.GetDatabase(); var mapper = this.GetMapper(); var firstProp = new Property { Id = 1, IsActual = true, Description = "A lot of", Address = "Drujba", Name = "Warehouse", Area = 300, Type = PropertyType.Warehouse }; var secondProp = new Property { Id = 2, IsActual = true, Description = "None" }; await db.Properties.AddRangeAsync(firstProp, secondProp); await db.SaveChangesAsync(); var propertyService = new PropertiesService(mapper, db); //Act var result = await propertyService.GetAsync(3); //Assert result .Should() .BeNull(); }
public async Task GetAsync_SouldReturn_PropertyWithDetails_IfPropertyExist() { var db = this.GetDatabase(); var mapper = this.GetMapper(); var firstProp = new Property { Id = 1, IsActual = true, Description = "A lot of", Address = "Drujba", Name = "Warehouse", Area = 300, Type = PropertyType.Warehouse }; var secondProp = new Property { Id = 2, IsActual = true, Description = "None" }; await db.Properties.AddRangeAsync(firstProp, secondProp); await db.SaveChangesAsync(); var propertyService = new PropertiesService(mapper, db); //Act var result = await propertyService.GetAsync(1); //Assert result .Should() .BeOfType <PropertyDetailsModel>() .And .Match <PropertyDetailsModel>(p => p.IsActual == true && p.Description == "A lot of" && p.Address == "Drujba" && p.Name == "Warehouse" && p.Area == 300 && p.Type == PropertyType.Warehouse); }