public async Task Delete_AnyEntityWithCreate_RepositoryDeletesOrCreatesEntity()
        {
            // Arrange
            int id = 1;

            // Act
            var result = await controller.Delete(id) as OkResult;

            // Assert
            result.Should().NotBeNull();
            A.CallTo(() => repository.Delete(id)).MustHaveHappenedOnceExactly();
        }
Exemplo n.º 2
0
        public void Delete_ExistingEntity_EntityDeleted()
        {
            // Arrange
            var entities = new[] {
                new AnyEntity
                {
                    Id        = 1,
                    AnyString = "AnyString"
                },
                new AnyEntity
                {
                    Id        = 2,
                    AnyString = "AnyString"
                }
            };

            dbContext.AnyEntities.AddRange(entities);
            dbContext.SaveChanges();
            dbContext.AnyEntities.Should().Contain(entities);

            // Act
            repository.Delete(1);
            dbContext.SaveChanges();

            // Assert
            dbContext.AnyEntities.First().Should().BeEquivalentTo(entities.Last());
        }