예제 #1
0
        public async Task CheckForPresenceOfAuthAppForCurrentUser_GivenUserDoesExist_ExpectPresentStatus()
        {
            var currentAuthenticatedUserProvider = new Mock <ICurrentAuthenticatedUserProvider>();

            currentAuthenticatedUserProvider.Setup(x => x.CurrentAuthenticatedUser).Returns(
                Maybe.From(
                    new AuthenticatedUser(TestVariables.UserId, "email-address", "first-name", "last-name") as ISystemUser));
            var connection = new Mock <IDbConnection>();

            connection.SetupDapperAsync(c => c.QueryAsync <PresenceCheckDto <Guid> >(
                                            It.IsAny <string>(),
                                            It.IsAny <DynamicParameters>(),
                                            null, null, It.IsAny <CommandType>()))
            .ReturnsAsync(() => new List <PresenceCheckDto <Guid> >
            {
                new PresenceCheckDto <Guid>(),
            });

            var dbConnectionProvider = new Mock <IConnectionProvider>();

            dbConnectionProvider.Setup(x => x.GetConnection())
            .Returns(() => connection.Object);

            var userQueries = new UserQueries(currentAuthenticatedUserProvider.Object, dbConnectionProvider.Object);
            var result      = await userQueries.CheckForPresenceOfAuthAppForCurrentUser();

            Assert.True(result.IsPresent);
        }
예제 #2
0
        public async Task CheckForPresenceOfAuthAppForCurrentUser_GivenNoUserIsAuthenticated_ExpectPresentStatus()
        {
            var currentAuthenticatedUserProvider = new Mock <ICurrentAuthenticatedUserProvider>();

            currentAuthenticatedUserProvider.Setup(x => x.CurrentAuthenticatedUser).Returns(Maybe <ISystemUser> .Nothing);

            var dbConnectionProvider = new Mock <IConnectionProvider>();

            var userQueries = new UserQueries(currentAuthenticatedUserProvider.Object, dbConnectionProvider.Object);
            var result      = await userQueries.CheckForPresenceOfAuthAppForCurrentUser();

            Assert.True(result.IsPresent);
        }