public void ThrowArgumentNullException_WhenNullUserEntitiePassed()
        {
            // Arrange
            var userRepositoryMock = new UserRepositoryMock();

            // Act && Assert
            Assert.ThrowsException <ArgumentNullException>(() => userRepositoryMock.Update(null));
        }
        public void UpdateUserEntitieInDatabase_WhenValidUserEntitiePassed()
        {
            // Arrange
            var userRepositoryMock = new UserRepositoryMock();

            var userMock = new Mock <IUserEntitie>();

            userMock.SetupGet(u => u.Username).Returns("Ivan");
            userMock.SetupGet(u => u.Password).Returns("12356");

            // Act
            userRepositoryMock.Update(userMock.Object);

            // Assert
            Assert.AreEqual(userMock.Object, userRepositoryMock.FakeLiteDb.Single());
        }
Exemple #3
0
        public void CanEditUser()
        {
            User user = new User
            {
                Email                = "*****@*****.**",
                EmailConfirmed       = false,
                LockoutEnabled       = false,
                LockoutEndDateUtc    = new DateTime(2018, 1, 1),
                AccessFailedCount    = 0,
                UserName             = "******",
                PhoneNumberConfirmed = false,
                TwoFactorEnabled     = false,
            };

            repo.Insert(user);

            user.Email                = "*****@*****.**";
            user.EmailConfirmed       = true;
            user.LockoutEndDateUtc    = new DateTime(2018, 1, 2);
            user.AccessFailedCount    = 1;
            user.UserName             = "******";
            user.PhoneNumberConfirmed = true;
            user.TwoFactorEnabled     = true;

            repo.Update(user);

            List <User> users = repo.GetUsers().ToList();

            Assert.AreEqual(5, users.Count);

            Assert.AreEqual("Added-Test-User", users[4].Id);
            Assert.AreEqual("*****@*****.**", users[4].Email);
            Assert.AreEqual("Updated Test User", users[4].UserName);
            Assert.AreEqual(1, users[4].AccessFailedCount);
            Assert.IsTrue(users[4].EmailConfirmed);
            Assert.IsTrue(users[4].PhoneNumberConfirmed);
            Assert.IsTrue(users[4].TwoFactorEnabled);
            Assert.IsFalse(users[4].LockoutEnabled);
        }