Example #1
0
        public void ProcedureExecuteOutDuplicate()
        {
            Guid?userId    = null;
            int  errorCode = -1;

            var username = "******" + DateTime.Now.Ticks;
            var email    = username + "@email.com";
            int result;

            using (var session = new DataSession("AspNet").Log(Console.WriteLine))
            {
                session.Should().NotBeNull();

                result = session.StoredProcedure("[dbo].[aspnet_Membership_CreateUser]")
                         .Parameter("@ApplicationName", "/")
                         .Parameter("@UserName", "paul.welter")
                         .Parameter("@Password", "T@est" + DateTime.Now.Ticks)
                         .Parameter("@Email", email)
                         .Parameter("@PasswordSalt", "test salt")
                         .Parameter <string>("@PasswordQuestion", null)
                         .Parameter <string>("@PasswordAnswer", null)
                         .Parameter("@IsApproved", true)
                         .Parameter("@CurrentTimeUtc", DateTime.UtcNow)
                         .Parameter("@UniqueEmail", 1)
                         .Parameter("@PasswordFormat", 1)
                         .Parameter <Guid?>(parameter => parameter
                                            .Name("@UserId")
                                            .Type(DbType.Guid)
                                            .Output(p => userId = p)
                                            .Direction(ParameterDirection.Output)
                                            )
                         .Return <int>(p => errorCode = p)
                         .Execute();

                // Duplicate
                result = session.StoredProcedure("[dbo].[aspnet_Membership_CreateUser]")
                         .Parameter("@ApplicationName", "/")
                         .Parameter("@UserName", "paul.welter")
                         .Parameter("@Password", "T@est" + DateTime.Now.Ticks)
                         .Parameter("@Email", email)
                         .Parameter("@PasswordSalt", "test salt")
                         .Parameter <string>("@PasswordQuestion", null)
                         .Parameter <string>("@PasswordAnswer", null)
                         .Parameter("@IsApproved", true)
                         .Parameter("@CurrentTimeUtc", DateTime.UtcNow)
                         .Parameter("@UniqueEmail", 1)
                         .Parameter("@PasswordFormat", 1)
                         .Parameter <Guid?>(parameter => parameter
                                            .Name("@UserId")
                                            .Type(DbType.Guid)
                                            .Output(p => userId = p)
                                            .Direction(ParameterDirection.Output)
                                            )
                         .Return <int>(p => errorCode = p)
                         .Execute();
            }

            result.Should().Be(-1);
            errorCode.Should().BeGreaterThan(0);
        }
Example #2
0
        public void ProcedureExecuteOut()
        {
            Guid userId    = Guid.Empty;
            int  errorCode = -1;

            var username = "******" + DateTime.Now.Ticks;
            var email    = username + "@email.com";

            int result;

            using (var session = new DataSession("AspNet").Log(Console.WriteLine))
            {
                session.Should().NotBeNull();
                result = session.StoredProcedure("[dbo].[aspnet_Membership_CreateUser]")
                         .Parameter("@ApplicationName", "/")
                         .Parameter("@UserName", username)
                         .Parameter("@Password", "T@est" + DateTime.Now.Ticks)
                         .Parameter("@Email", email)
                         .Parameter("@PasswordSalt", "test salt")
                         .Parameter <string>("@PasswordQuestion", null)
                         .Parameter <string>("@PasswordAnswer", null)
                         .Parameter("@IsApproved", true)
                         .Parameter("@CurrentTimeUtc", DateTime.UtcNow)
                         .Parameter("@UniqueEmail", 1)
                         .Parameter("@PasswordFormat", 1)
                         .ParameterOut <Guid>("@UserId", p => userId = p)
                         .Return <int>(p => errorCode = p)
                         .Execute();
            }

            result.Should().BeGreaterOrEqualTo(1);
            userId.Should().NotBe(Guid.Empty);
            errorCode.Should().Be(0);
        }
Example #3
0
        public void ProcedureQueryDynamicOut()
        {
            int totalRecords = -1;
            int result       = 0;

            Guid userId    = Guid.Empty;
            int  errorCode = -1;

            var username = "******" + DateTime.Now.Ticks;
            var email    = username + "@email.com";

            List <dynamic> results;

            using (var session = new DataSession("AspNet").Log(Console.WriteLine))
            {
                session.Should().NotBeNull();

                result = session.StoredProcedure("[dbo].[aspnet_Membership_CreateUser]")
                         .Parameter("@ApplicationName", "/")
                         .Parameter("@UserName", username)
                         .Parameter("@Password", "T@est" + DateTime.Now.Ticks)
                         .Parameter("@Email", email)
                         .Parameter("@PasswordSalt", "test salt")
                         .Parameter <string>("@PasswordQuestion", null)
                         .Parameter <string>("@PasswordAnswer", null)
                         .Parameter("@IsApproved", true)
                         .Parameter("@CurrentTimeUtc", DateTime.UtcNow)
                         .Parameter("@UniqueEmail", 1)
                         .Parameter("@PasswordFormat", 1)
                         .ParameterOut <Guid>("@UserId", p => userId = p)
                         .Return <int>(p => errorCode = p)
                         .Execute();

                results = session.StoredProcedure("[dbo].[aspnet_Membership_FindUsersByEmail]")
                          .Parameter("@ApplicationName", "/")
                          .Parameter("@EmailToMatch", "*****@*****.**")
                          .Parameter("@PageIndex", 0)
                          .Parameter("@PageSize", 10)
                          .Return <int>(p => totalRecords = p)
                          .Query()
                          .ToList();
            }

            results.Should().NotBeNull();
            results.Count.Should().BeGreaterThan(0);
            totalRecords.Should().BeGreaterThan(0);
        }
Example #4
0
        public string GenerateEntityUniqueSequence <TEntity>() where TEntity : IDvHubEntity
        {
            string result = string.Empty;

            var sequenceName = EntityHelper.GetEntityUniqueSequenceName <TEntity>();

            DataSession.StoredProcedure("GetUniqueSequence")
            .Parameter("SeqName", sequenceName)
            .Return <string>(p => result = p)
            .Execute();

            return(result);
        }
        public void ProcedureExecuteTransaction()
        {
            var session = new DataSession("AspNet").Log(Console.WriteLine);
            session.Should().NotBeNull();

            var transaction = session.BeginTransaction(IsolationLevel.Unspecified);
            transaction.Should().NotBeNull();

            Guid userId = Guid.Empty;
            int errorCode = -1;

            var username = "******" + DateTime.Now.Ticks;
            var email = username + "@email.com";

            var result = session.StoredProcedure("[dbo].[aspnet_Membership_CreateUser]")
                .Parameter("@ApplicationName", "/")
                .Parameter("@UserName", username)
                .Parameter("@Password", "T@est" + DateTime.Now.Ticks)
                .Parameter("@Email", email)
                .Parameter("@PasswordSalt", "test salt")
                .Parameter<string>("@PasswordQuestion", null)
                .Parameter<string>("@PasswordAnswer", null)
                .Parameter("@IsApproved", true)
                .Parameter("@CurrentTimeUtc", DateTime.UtcNow)
                .Parameter("@UniqueEmail", 1)
                .Parameter("@PasswordFormat", 1)
                .ParameterOut<Guid>("@UserId", p => userId = p)
                .Return<int>(p => errorCode = p)
                .Execute();

            result.Should().BeGreaterOrEqualTo(1);
            userId.Should().NotBe(Guid.Empty);
            errorCode.Should().Be(0);

            transaction.Commit();
        }
        public void ProcedureQueryDynamicOut()
        {
            int totalRecords = -1;
            int result = 0;

            Guid userId = Guid.Empty;
            int errorCode = -1;

            var username = "******" + DateTime.Now.Ticks;
            var email = username + "@email.com";

            List<dynamic> results;
            using (var session = new DataSession("AspNet").Log(Console.WriteLine))
            {
                session.Should().NotBeNull();

                result = session.StoredProcedure("[dbo].[aspnet_Membership_CreateUser]")
                    .Parameter("@ApplicationName", "/")
                    .Parameter("@UserName", username)
                    .Parameter("@Password", "T@est" + DateTime.Now.Ticks)
                    .Parameter("@Email", email)
                    .Parameter("@PasswordSalt", "test salt")
                    .Parameter<string>("@PasswordQuestion", null)
                    .Parameter<string>("@PasswordAnswer", null)
                    .Parameter("@IsApproved", true)
                    .Parameter("@CurrentTimeUtc", DateTime.UtcNow)
                    .Parameter("@UniqueEmail", 1)
                    .Parameter("@PasswordFormat", 1)
                    .ParameterOut<Guid>("@UserId", p => userId = p)
                    .Return<int>(p => errorCode = p)
                    .Execute();

                results = session.StoredProcedure("[dbo].[aspnet_Membership_FindUsersByEmail]")
                    .Parameter("@ApplicationName", "/")
                    .Parameter("@EmailToMatch", "*****@*****.**")
                    .Parameter("@PageIndex", 0)
                    .Parameter("@PageSize", 10)
                    .Return<int>(p => totalRecords = p)
                    .Query()
                    .ToList();
            }

            results.Should().NotBeNull();
            results.Count.Should().BeGreaterThan(0);
            totalRecords.Should().BeGreaterThan(0);
        }
        public void ProcedureExecuteOutDuplicate()
        {

            Guid? userId = null;
            int errorCode = -1;

            var username = "******" + DateTime.Now.Ticks;
            var email = username + "@email.com";
            int result;

            using (var session = new DataSession("AspNet").Log(Console.WriteLine))
            {
                session.Should().NotBeNull();

                result = session.StoredProcedure("[dbo].[aspnet_Membership_CreateUser]")
                    .Parameter("@ApplicationName", "/")
                    .Parameter("@UserName", "paul.welter")
                    .Parameter("@Password", "T@est" + DateTime.Now.Ticks)
                    .Parameter("@Email", email)
                    .Parameter("@PasswordSalt", "test salt")
                    .Parameter<string>("@PasswordQuestion", null)
                    .Parameter<string>("@PasswordAnswer", null)
                    .Parameter("@IsApproved", true)
                    .Parameter("@CurrentTimeUtc", DateTime.UtcNow)
                    .Parameter("@UniqueEmail", 1)
                    .Parameter("@PasswordFormat", 1)
                    .Parameter<Guid?>(parameter => parameter
                        .Name("@UserId")
                        .Type(DbType.Guid)
                        .Output(p => userId = p)
                        .Direction(ParameterDirection.Output)
                    )
                    .Return<int>(p => errorCode = p)
                    .Execute();

                // Duplicate
                result = session.StoredProcedure("[dbo].[aspnet_Membership_CreateUser]")
                    .Parameter("@ApplicationName", "/")
                    .Parameter("@UserName", "paul.welter")
                    .Parameter("@Password", "T@est" + DateTime.Now.Ticks)
                    .Parameter("@Email", email)
                    .Parameter("@PasswordSalt", "test salt")
                    .Parameter<string>("@PasswordQuestion", null)
                    .Parameter<string>("@PasswordAnswer", null)
                    .Parameter("@IsApproved", true)
                    .Parameter("@CurrentTimeUtc", DateTime.UtcNow)
                    .Parameter("@UniqueEmail", 1)
                    .Parameter("@PasswordFormat", 1)
                    .Parameter<Guid?>(parameter => parameter
                        .Name("@UserId")
                        .Type(DbType.Guid)
                        .Output(p => userId = p)
                        .Direction(ParameterDirection.Output)
                    )
                    .Return<int>(p => errorCode = p)
                    .Execute();
            }

            result.Should().Be(-1);
            errorCode.Should().BeGreaterThan(0);

        }