示例#1
0
        public async Task RegisterNewUserCommand_Test()
        {
            var registrationId = await UserAccessModule.ExecuteCommandAsync(new RegisterNewUserCommand(
                                                                                UserRegistrationSampleData.Login,
                                                                                UserRegistrationSampleData.Password,
                                                                                UserRegistrationSampleData.Email,
                                                                                UserRegistrationSampleData.FirstName,
                                                                                UserRegistrationSampleData.LastName,
                                                                                "confirmLink"));

            var userRegistration = await UserAccessModule.ExecuteQueryAsync(new GetUserRegistrationQuery(registrationId));

            Assert.That(userRegistration.Email, Is.EqualTo(UserRegistrationSampleData.Email));
            Assert.That(userRegistration.Login, Is.EqualTo(UserRegistrationSampleData.Login));
            Assert.That(userRegistration.FirstName, Is.EqualTo(UserRegistrationSampleData.FirstName));
            Assert.That(userRegistration.LastName, Is.EqualTo(UserRegistrationSampleData.LastName));

            var connection   = new SqlConnection(ConnectionString);
            var messagesList = await OutboxMessagesHelper.GetOutboxMessages(connection);

            Assert.That(messagesList.Count, Is.EqualTo(1));

            var newUserRegisteredNotification =
                await GetLastOutboxMessage <NewUserRegisteredNotification>();

            Assert.That(newUserRegisteredNotification.DomainEvent.Login, Is.EqualTo(UserRegistrationSampleData.Login));
        }
示例#2
0
        public async Task CreatePhraseCommand_Test()
        {
            var phraseId = await PhraseModule.ExecuteCommandAsync(new CreatePhraseCommand(
                                                                      PhraseSampleData.MatchId,
                                                                      PhraseSampleData.TeamId,
                                                                      PhraseSampleData.CreatedByUserId,
                                                                      PhraseSampleData.Description,
                                                                      PhraseSampleData.Positive));

            var phrase = await PhraseModule.ExecuteQueryAsync(new GetPhraseQuery(phraseId));

            Assert.That(phrase.MatchId, Is.EqualTo(PhraseSampleData.MatchId));
            Assert.That(phrase.TeamId, Is.EqualTo(PhraseSampleData.TeamId));
            Assert.That(phrase.CreatedByUserId, Is.EqualTo(PhraseSampleData.CreatedByUserId));
            Assert.That(phrase.Description, Is.EqualTo(PhraseSampleData.Description));
            Assert.That(phrase.Positive, Is.EqualTo(PhraseSampleData.Positive));

            var connection   = new SqlConnection(ConnectionString);
            var messagesList = await OutboxMessagesHelper.GetOutboxMessages(connection);

            Assert.That(messagesList.Count, Is.EqualTo(1));

            var newUserRegisteredNotification = await GetLastOutboxMessage <PhraseCreatedNotification>();

            Assert.That(newUserRegisteredNotification.DomainEvent.MatchId.Value, Is.EqualTo(PhraseSampleData.MatchId));
            Assert.That(newUserRegisteredNotification.DomainEvent.TeamId.Value, Is.EqualTo(PhraseSampleData.TeamId));
            Assert.That(newUserRegisteredNotification.DomainEvent.CreatedByUserId.Value, Is.EqualTo(PhraseSampleData.CreatedByUserId));
            Assert.That(newUserRegisteredNotification.DomainEvent.Description, Is.EqualTo(PhraseSampleData.Description));
            Assert.That(newUserRegisteredNotification.DomainEvent.Positive, Is.EqualTo(PhraseSampleData.Positive));
        }
        public async Task PlaceOrder_Test()
        {
            string      customerEmail = "*****@*****.**";
            CustomerDto customer      =
                await CommandsExecutor.Execute(new RegisterCustomerCommand(customerEmail, "Sample Customer"));

            List <ProductDto> products = new List <ProductDto>();
            Guid productId             = Guid.Parse("9DB6E474-AE74-4CF5-A0DC-BA23A42E2566");

            products.Add(new ProductDto(productId, 2));
            Guid orderId = await CommandsExecutor.Execute(new PlaceCustomerOrderCommand(customer.Id, products, "EUR"));

            OrderDetailsDto orderDetails = await QueriesExecutor.Execute(new GetCustomerOrderDetailsQuery(orderId));

            Assert.That(orderDetails, Is.Not.Null);
            Assert.That(orderDetails.Value, Is.EqualTo(70));
            Assert.That(orderDetails.Products.Count, Is.EqualTo(1));
            Assert.That(orderDetails.Products[0].Quantity, Is.EqualTo(2));
            Assert.That(orderDetails.Products[0].Id, Is.EqualTo(productId));

            SqlConnection           connection   = new SqlConnection(ConnectionString);
            List <OutboxMessageDto> messagesList = await OutboxMessagesHelper.GetOutboxMessages(connection);

            Assert.That(messagesList.Count, Is.EqualTo(3));

            CustomerRegisteredNotification customerRegisteredNotification =
                OutboxMessagesHelper.Deserialize <CustomerRegisteredNotification>(messagesList[0]);

            Assert.That(customerRegisteredNotification.CustomerId, Is.EqualTo(new CustomerId(customer.Id)));

            OrderPlacedNotification orderPlaced =
                OutboxMessagesHelper.Deserialize <OrderPlacedNotification>(messagesList[1]);

            Assert.That(orderPlaced.OrderId, Is.EqualTo(new OrderId(orderId)));

            PaymentCreatedNotification paymentCreated =
                OutboxMessagesHelper.Deserialize <PaymentCreatedNotification>(messagesList[2]);

            Assert.That(paymentCreated, Is.Not.Null);
        }
示例#4
0
        public async Task PlaceOrder_Test()
        {
            var customerEmail = "*****@*****.**";
            var customer      = await CommandsExecutor.Execute(new RegisterCustomerCommand(customerEmail, "soheil bijavar"));

            List <ProductDto> products = new List <ProductDto>();
            var productId = Guid.Parse("cdd19ddd-647a-4af7-9f95-cfef9e346c40");

            products.Add(new ProductDto(productId, 2));
            var orderId = await CommandsExecutor.Execute(new PlaceCustomerOrderCommand(customer.Id, products, "Rial"));

            var orderDetails = await QueriesExecutor.Execute(new GetCustomerOrderDetailsQuery(orderId));

            Assert.That(orderDetails, Is.Not.Null);
            Assert.That(orderDetails.Value, Is.EqualTo(80));
            Assert.That(orderDetails.Products.Count, Is.EqualTo(1));
            Assert.That(orderDetails.Products[0].Quantity, Is.EqualTo(2));
            Assert.That(orderDetails.Products[0].Id, Is.EqualTo(productId));

            var connection   = new SqlConnection(ConnectionString);
            var messagesList = await OutboxMessagesHelper.GetOutboxMessages(connection);

            Assert.That(messagesList.Count, Is.EqualTo(3));

            var customerRegisteredNotification =
                OutboxMessagesHelper.Deserialize <CustomerRegisteredNotification>(messagesList[0]);

            Assert.That(customerRegisteredNotification.CustomerId, Is.EqualTo(new CustomerId(customer.Id)));

            var orderPlaced =
                OutboxMessagesHelper.Deserialize <OrderPlacedNotification>(messagesList[1]);

            Assert.That(orderPlaced.OrderId, Is.EqualTo(new OrderId(orderId)));

            var paymentCreated =
                OutboxMessagesHelper.Deserialize <PaymentCreatedNotification>(messagesList[2]);

            Assert.That(paymentCreated, Is.Not.Null);
        }
示例#5
0
        public async Task RegisterCustomerTest()
        {
            const string email = "*****@*****.**";
            const string name  = "soheil bijavar company";

            var customer = await CommandsExecutor.Execute(new RegisterCustomerCommand(email, name));

            var customerDetails = await QueriesExecutor.Execute(new GetCustomerDetailsQuery(customer.Id));

            Assert.That(customerDetails, Is.Not.Null);
            Assert.That(customerDetails.Name, Is.EqualTo(name));
            Assert.That(customerDetails.Email, Is.EqualTo(email));

            var connection   = new SqlConnection(ConnectionString);
            var messagesList = await OutboxMessagesHelper.GetOutboxMessages(connection);

            Assert.That(messagesList.Count, Is.EqualTo(1));

            var customerRegisteredNotification =
                OutboxMessagesHelper.Deserialize <CustomerRegisteredNotification>(messagesList[0]);

            Assert.That(customerRegisteredNotification.CustomerId, Is.EqualTo(new CustomerId(customer.Id)));
        }