public async Task Return_AppUserWithCorrectAttributes_WhenValidIdPassed()
        {
            var options = TestUtils.GetOptions(nameof(Return_AppUserWithCorrectAttributes_WhenValidIdPassed));

            var userStoreMocked   = new Mock <IUserStore <AppUser> >();
            var userManagerMocked =
                new Mock <UserManager <AppUser> >
                    (userStoreMocked.Object, null, null, null, null, null, null, null, null);

            using (var arrangeContext = new CMContext(options))
            {
                //1
                arrangeContext.Users.Add(new AppUser {
                    Id = "1", UserName = "******"
                });

                //2
                arrangeContext.Users.Add(new AppUser {
                    Id = "2", UserName = "******"
                });

                //3
                arrangeContext.Users.Add(new AppUser {
                    Id = "3", UserName = "******"
                });

                await arrangeContext.SaveChangesAsync();
            }
            using (var assertContext = new CMContext(options))
            {
                var sut = new AppUserServices(assertContext, userManagerMocked.Object);

                var result = await sut.GetUserByID("3");

                Assert.AreEqual("user3", result.UserName);
                Assert.AreEqual("3", result.Id);
                Assert.IsInstanceOfType(result, typeof(AppUser));
            }
        }
        public async Task Throw_CorrectMagicExeption_NullValueIdPassed()
        {
            var options = TestUtils.GetOptions(nameof(Throw_CorrectMagicExeption_NullValueIdPassed));

            var userStoreMocked   = new Mock <IUserStore <AppUser> >();
            var userManagerMocked =
                new Mock <UserManager <AppUser> >
                    (userStoreMocked.Object, null, null, null, null, null, null, null, null);

            using (var arrangeContext = new CMContext(options))
            {
                //1
                arrangeContext.Users.Add(new AppUser {
                    Id = "1", UserName = "******"
                });

                //2
                arrangeContext.Users.Add(new AppUser {
                    Id = "2", UserName = "******"
                });

                //3
                arrangeContext.Users.Add(new AppUser {
                    Id = "3", UserName = "******"
                });

                await arrangeContext.SaveChangesAsync();
            }
            using (var assertContext = new CMContext(options))
            {
                var sut = new AppUserServices(assertContext, userManagerMocked.Object);

                var result = await Assert.ThrowsExceptionAsync <MagicException>
                                 (async() => await sut.GetUserByID(null));

                Assert.AreEqual("ID cannot be null!", result.Message);
            }
        }
        public async Task Throw_MagicExeption_IfUserWithThisID_DoesNotExist()
        {
            var options = TestUtils.GetOptions(nameof(Throw_MagicExeption_IfUserWithThisID_DoesNotExist));

            var userStoreMocked   = new Mock <IUserStore <AppUser> >();
            var userManagerMocked =
                new Mock <UserManager <AppUser> >
                    (userStoreMocked.Object, null, null, null, null, null, null, null, null);

            using (var arrangeContext = new CMContext(options))
            {
                //1
                arrangeContext.Users.Add(new AppUser {
                    Id = "1", UserName = "******"
                });

                //2
                arrangeContext.Users.Add(new AppUser {
                    Id = "2", UserName = "******"
                });

                //3
                arrangeContext.Users.Add(new AppUser {
                    Id = "3", UserName = "******"
                });

                await arrangeContext.SaveChangesAsync();
            }
            using (var assertContext = new CMContext(options))
            {
                var sut = new AppUserServices(assertContext, userManagerMocked.Object);

                var result = await Assert.ThrowsExceptionAsync <MagicException>
                                 (async() => await sut.GetUserByID("dasda"));
            }
        }