Esempio n. 1
0
        public void Put_WithMockedModel_ShouldBeCalledOnce()
        {
            // Arrange
            var actualId       = 4399;
            var dummyString    = Guid.NewGuid().ToString().Replace("-", "");
            var mockRepository = new Mock <IEntryRepository>();
            var dbModel        = new EntryModel()
            {
                CategoryId      = 4400,
                SubCategoryId   = 4401,
                LexiconFunction = dummyString,
                Recommendation  = "delectus",
                Notes           = "voluptatibus",
            };

            mockRepository
            .Setup(m => m.Update(dbModel));

            var controller = new EntryController(mockRepository.Object);

            // Act
            controller.Put(actualId, dbModel);

            // Assert
            mockRepository
            .Verify(m => m.Update(
                        It.Is <EntryModel>(
                            i => i.Id == actualId && i.LexiconFunction == dummyString)),
                    Times.Once());
        }