public async Task Create_AnyEntity_RepositoryCreatesEntity()
        {
            // Arrange
            var entity = new AnyEntity
            {
                AnyString = "AnyString"
            };

            // Act
            var result = await controller.Create(entity) as OkResult;

            // Assert
            result.Should().NotBeNull();
            A.CallTo(() => repository.Create(entity)).MustHaveHappenedOnceExactly();
        }
        public void Create_AnyEntity_EntityCreated()
        {
            // Arrange
            var expected = new AnyEntity
            {
                AnyString = "AnyString"
            };

            // Act
            repository.Create(expected);
            dbContext.SaveChanges();

            // Assert
            dbContext.AnyEntities.First().AnyString.Should().Be(expected.AnyString);
        }
Beispiel #3
0
        public void Create_AnyModel_ModelCreated()
        {
            // Arrange
            var model = new AnyModel
            {
                Id        = ObjectId.GenerateNewId().ToString(),
                AnyString = "AnyString"
            };

            // Act
            var result = _controller.Create(model) as OkResult;

            // Assert
            result.Should().NotBeNull();
            result.StatusCode.Should().Be(200);
            A.CallTo(() => _repository.Create(model)).MustHaveHappenedOnceExactly();
        }