Пример #1
0
        public void ShouldRemoveUserInMemory()
        {
            var user = new User()
            {
                Email          = "*****@*****.**",
                Guid           = System.Guid.NewGuid().ToString(),
                HashedPassword = "******",
                Name           = "name",
                Role           = "admin",
                Surname        = "dksk"
            };

            var mockSet = new MockDbSet <User>();

            var mockContext = new Mock <WorkSiteDbContext>();

            mockContext.Setup(c => c.Set <User>()).Returns(mockSet.Object);

            using (var uow = new WorkSiteUow(mockContext.Object))
            {
                uow.Users.Create(user);
                uow.Save();
                uow.Users.Delete(user.Guid);
                uow.Save();
            }

            mockSet.Verify(u => u.Remove(It.IsNotIn(user)), Times.Never);
        }
        public async Task Given_ATestDtoObject_When_InsertIsInvoked_Then_AddMethodShouldBeInvokedOnlyOnce()
        {
            await DbContextBase.Create(new DateRangeEffectiveDtoObject());

            MockDbSet.Verify(m => m.Add(It.IsAny <DateRangeEffectiveDtoObject>()), Times.Once());
        }
        public async Task Given_AValidTestDtoObjectId_When_DeleteIsInvoked_Then_RemoveMethodShouldOnlyBeInvokedOnce()
        {
            await DbContextBase.Delete(StaticTestValues.ValidId1);

            MockDbSet.Verify(m => m.Remove(It.Is <DateRangeEffectiveDtoObject>(s => s.Id == StaticTestValues.ValidId1)), Times.Once());
        }