Beispiel #1
0
        private User SetUserAttributes(User user)
        {
            user.UserId      = Guid.NewGuid();
            user.FirstName   = UnitTestUtil.getRandomString(8);
            user.LastName    = UnitTestUtil.getRandomString(8);
            user.AuthString  = UnitTestUtil.getRandomString(8);
            user.EndlasEmail = UnitTestUtil.getRandomString(8) + "@endlas.com";

            return(user);
        }
Beispiel #2
0
        public async Task UserUpdateTestAsync()
        {
            var   repo = new Repo(_db);
            Admin user = CreateAdmin();

            await AddForTest(user);

            var  originalEmail = user.EndlasEmail;
            User usercopy      = user;

            // change user attributes
            user.FirstName   = UnitTestUtil.getRandomString(8);
            user.LastName    = UnitTestUtil.getRandomString(8);
            user.EndlasEmail = UnitTestUtil.getRandomString(9) + "@endlas.com";
            await repo.UpdateAdmin(user);

            var result    = await(_db.Users.Where(p => p.EndlasEmail == user.EndlasEmail).FirstOrDefaultAsync());
            var badresult = await(_db.Users.Where(p => p.EndlasEmail == originalEmail).FirstOrDefaultAsync());

            Assert.AreEqual(user.EndlasEmail, result.EndlasEmail);
            Assert.IsNull(badresult);
        }
Beispiel #3
0
        public async Task UserAddTestAsync()
        {
            /// ARRANGE

            // setup PilotRepo to be tested
            var repo = new Repo(_db);
            // setup pilot with name, email, aircraft and a password
            var user = new Admin {
                UserId     = Guid.NewGuid(), FirstName = UnitTestUtil.getRandomString(8),
                LastName   = UnitTestUtil.getRandomString(8), EndlasEmail = UnitTestUtil.getRandomString(8) + "@endlas.com",
                AuthString = UnitTestUtil.getRandomString(8)
            };

            /// ACT
            // call the method to be tested
            await repo.AddAdmin(user);

            var result = await(_db.Users.Where(p => p.EndlasEmail == user.EndlasEmail).FirstOrDefaultAsync());

            /// ASSERT
            Assert.IsNotNull(result);
            Assert.AreEqual(result.EndlasEmail, user.EndlasEmail);
        }