Пример #1
0
        public async Task Person_is_deleted()
        {
            var person = MockContext.Object.Persons.First(p => p.TaxCode == "taxcode1");

            await PersonService.DeletePerson(person);

            MockSet.Verify(m => m.Remove(person), Times.Once);
            MockContext.Object.Persons.Count().ShouldBeEquivalentTo(1);
            MockContext.Verify(m => m.SaveChangesAsync(), Times.Once);
        }
Пример #2
0
        public void ItExists()
        {
            // Arrange
            // Act
            var thing = Repository.Get(It.IsAny <int>());

            // Assert
            Assert.Null(thing);
            MockSet.Verify(set => set.Find(It.IsAny <int>()), Times.Once);
        }
Пример #3
0
        public async Task New_person_is_saved()
        {
            var person = new Person()
            {
                TaxCode   = "taxcode3",
                Firstname = "firstname3",
                Surname   = "surname3"
            };

            await PersonService.AddPerson(person);

            MockSet.Verify(m => m.Add(person), Times.Once);
            MockContext.Object.Persons.Count().ShouldBeEquivalentTo(3);
            MockContext.Verify(m => m.SaveChangesAsync(), Times.Once);
        }