Example #1
0
        public async Task Test()
        {
            using (AsyncScopedLifestyle.BeginScope(ContainerFactory.Instance))
            {
                Guid id = Guid.NewGuid();

                Create.Command command = new Create.Command
                {
                    Id             = id,
                    Name           = "Integration test " + DateTime.UtcNow.Ticks,
                    LecturerName   = "Joe Bloggs",
                    NumberOfPlaces = 10
                };

                await Mediator().Send(command);

                SignUp.Command signUpCommand = new SignUp.Command
                {
                    Name     = "Terry Student",
                    Age      = 21,
                    CourseId = id
                };

                await Mediator().Send(signUpCommand);

                Assert.True(Notifications().WasReceived <Create.CourseCreated>());
                Assert.True(Notifications().WasReceived <SignUp.StudentSignedUp>());
            }
        }
        public async Task <ActionResult> SignUp(
            [FromBody] SignUp.Command command)
        {
            await mediator.Send(command);

            return(NoContent());
        }
Example #3
0
        public async Task Expect_Login_Account()
        {
            var email = "*****@*****.**";
            var pwd   = "1q2w3e4r";

            var accountCreate = new SignUp.Command()
            {
                Account = new SignUp.AccountSignUpDto
                {
                    Email         = email,
                    FullName      = "Test User",
                    Password      = pwd,
                    PasswordAgain = pwd
                }
            };

            var accountCreateResult = await SendAsync(accountCreate);

            Assert.NotNull(accountCreateResult);
            Assert.True(accountCreateResult.IsSucceeded);

            var command = new Login.Command()
            {
                Account = new Login.AccountLoginDto()
                {
                    Email    = email,
                    Password = pwd
                }
            };

            var loginResult = await SendAsync(command);

            Assert.NotNull(loginResult);
            Assert.True(loginResult.IsSucceeded);
        }
Example #4
0
        private Account GetGlobalTestAccount()
        {
            lock (Locker)
            {
                if (TestAccount == null)
                {
                    var email   = "*****@*****.**";
                    var pwd     = "1q2w3e4r";
                    var command = new SignUp.Command()
                    {
                        Account = new SignUp.AccountSignUpDto
                        {
                            Email         = email,
                            FullName      = "Test User",
                            Password      = pwd,
                            PasswordAgain = pwd
                        }
                    };

                    var result = SendAsync(command).GetAwaiter().GetResult();

                    var loginCmd = new Login.Command()
                    {
                        Account = new Login.AccountLoginDto()
                        {
                            Email    = email,
                            Password = pwd
                        }
                    };

                    var accountDto = SendAsync(loginCmd)
                                     .GetAwaiter()
                                     .GetResult()
                                     .Result;

                    TestAccount = new Account()
                    {
                        CreatedAt = DateTime.Now,
                        Email     = accountDto.Email,
                        FullName  = accountDto.FullName,
                        Id        = accountDto.Id,
                        Role      = "user"
                    };
                }

                return(TestAccount);
            }
        }
Example #5
0
        public async Task Expect_Create_Account()
        {
            var command = new SignUp.Command()
            {
                Account = new SignUp.AccountSignUpDto
                {
                    Email         = "*****@*****.**",
                    FullName      = "Test User",
                    Password      = "******",
                    PasswordAgain = "1q2w3e"
                }
            };

            var result = await SendAsync(command);

            Assert.NotNull(result);
            Assert.True(result.IsSucceeded);
        }