Example #1
0
        public async Task Return_WhenUserIsNotDeleted()
        {
            var userId    = "userId";
            var username  = "******";
            var email     = "*****@*****.**";
            var isDeleted = false;

            var logbooks = new List <int> {
                1
            };

            var userManagerWrapperMocked = new Mock <IUserManagerWrapper <User> >();
            var mappingProviderMocked    = new Mock <IMappingProvider>();
            var dateTimeWrapperMocked    = new Mock <IDateTimeWrapper>();

            var modifiedOn = dateTimeWrapperMocked.Object.Now();

            AccountTestUtils.GetContextWithFullUser(nameof(Return_WhenUserIsNotDeleted), userId, username, email);

            using (var assertContext = new AlphaHotelDbContext(AccountTestUtils.GetOptions(nameof(Return_WhenUserIsNotDeleted))))
            {
                var accountService = new AccountService(assertContext, userManagerWrapperMocked.Object, mappingProviderMocked.Object, dateTimeWrapperMocked.Object);

                await accountService.EditAccountAsync(userId, username, email, isDeleted, logbooks);

                var account = await assertContext.Users.FirstOrDefaultAsync(u => u.Id == userId);

                Assert.AreEqual(username, account.UserName);
                Assert.AreEqual(email, account.Email);
                Assert.IsFalse(account.IsDeleted);
                Assert.AreEqual(account.ModifiedOn, modifiedOn);
                Assert.AreEqual(account.UsersLogbooks.Count, 1);
            }
        }