public void GetAllBySpecificationId_ShouldReturnEmptyArray_WhenWrongSpecificationId() { // Arrange var context = GetContext(); var repo = new SqlStandardConstructionRepo(context); // Act var standardConstructions = repo.GetAllBySpecificationId(999); // Assert Assert.Empty(standardConstructions); context.Database.EnsureDeleted(); context.Dispose(); }
public void GetById_ShouldReturnstandardConstruction() { // Arrange var context = GetContext(); var repo = new SqlStandardConstructionRepo(context); int id = _rnd.Next(1, _standardConstructions.Count()); // Act var standardConstruction = repo.GetById(id); // Assert Assert.Equal(_standardConstructions.SingleOrDefault(v => v.Id == id), standardConstruction); context.Database.EnsureDeleted(); context.Dispose(); }
public void Delete_ShouldDeletestandardConstruction() { // Arrange var context = GetContext(); var repo = new SqlStandardConstructionRepo(context); int id = _rnd.Next(1, _standardConstructions.Count()); var standardConstruction = _standardConstructions.FirstOrDefault(v => v.Id == id); // Act repo.Delete(standardConstruction); // Assert Assert.Null(repo.GetById(id)); context.Database.EnsureDeleted(); context.Dispose(); }
public void GetAllBySpecificationId_ShouldReturnstandardConstructions() { // Arrange var context = GetContext(); var repo = new SqlStandardConstructionRepo(context); var specificationId = _rnd.Next(1, _maxSpecificationId); // Act var standardConstructions = repo.GetAllBySpecificationId(specificationId); // Assert Assert.Equal(_standardConstructions.Where( v => v.Specification.Id == specificationId), standardConstructions); context.Database.EnsureDeleted(); context.Dispose(); }
public void Update_ShouldUpdatestandardConstruction() { // Arrange var context = GetContext(true); var repo = new SqlStandardConstructionRepo(context); int id = _rnd.Next(1, _updateStandardConstructions.Count()); var standardConstruction = _updateStandardConstructions.FirstOrDefault(v => v.Id == id); standardConstruction.Name = "NewUpdate"; // Act repo.Update(standardConstruction); // Assert Assert.Equal(standardConstruction.Name, repo.GetById(id).Name); context.Database.EnsureDeleted(); context.Dispose(); }
public void GetByUniqueKey_ShouldReturnNull_WhenWrongKey() { // Arrange var context = GetContext(); var repo = new SqlStandardConstructionRepo(context); var specificationId = _standardConstructions[0].Specification.Id; var name = _standardConstructions[0].Name; // Act var additionalWork1 = repo.GetByUniqueKey(999, name); var additionalWork2 = repo.GetByUniqueKey(specificationId, "NotFound"); // Assert Assert.Null(additionalWork1); Assert.Null(additionalWork2); context.Database.EnsureDeleted(); context.Dispose(); }
public void GetByUniqueKey_ShouldReturnstandardConstruction() { // Arrange var context = GetContext(); var repo = new SqlStandardConstructionRepo(context); var specificationId = _standardConstructions[0].Specification.Id; var name = _standardConstructions[0].Name; // Act var standardConstruction = repo.GetByUniqueKey(specificationId, name); // Assert Assert.Equal(_standardConstructions.SingleOrDefault( v => v.Specification.Id == specificationId && v.Name == name), standardConstruction); context.Database.EnsureDeleted(); context.Dispose(); }