Esempio n. 1
0
        public async Task CanListOrderItems()
        {
            // Arrange
            const int orderItemCount = 3;
            var       users          = fixture.CreateMany <TestUser>(orderItemCount).ToArray();
            var       orderTexts     = fixture.CreateMany <string>(orderItemCount).ToArray();

            using (var conversation = BotClient.Instance.CreateConversation())
            {
                var supplierName = await supplierFixture.CreateSupplierAsync(conversation);

                for (var i = 0; i < orderItemCount; i++)
                {
                    await orderFixture.AddOrderItemAsync(conversation, supplierName, orderTexts[i], users[i]);
                }

                // Act
                var response = await CommandExecutor.ExecuteAndWaitForResponseAsync(
                    conversation,
                    $"#lista {supplierName}",
                    users.First());

                // Assert
                Assert.That(response, Contains.Substring($"Dostawca: **{supplierName}**"));

                for (var i = 0; i < orderItemCount; i++)
                {
                    Assert.That(response, Contains.Substring($"- [{users[i].Name}] **{orderTexts[i]}**"));
                }
            }
        }
Esempio n. 2
0
        public async Task CanPickOrderOperator()
        {
            // Arrange
            const int orderItemCount = 3;
            var       users          = fixture.CreateMany <TestUser>(orderItemCount).ToArray();

            using (var conversation = BotClient.Instance.CreateConversation())
            {
                var supplierName = await supplierFixture.CreateSupplierAsync(conversation);

                for (var i = 0; i < orderItemCount; i++)
                {
                    await orderFixture.AddOrderItemAsync(conversation, supplierName, user : users[i]);
                }

                // Act
                var response = await CommandExecutor.ExecuteAndWaitForResponseAsync(
                    conversation,
                    $"#losuj {supplierName}",
                    users.First());

                // Assert
                var pattern = $@"Operatorem zamówienia do '{supplierName}'  z dnia (.*)  zostaje \*\*({String.Join("|", users.Select(u => u.Name))})\*\*";
                StringAssert.IsMatch(pattern, response);

                Assert.That(response, Contains.Substring($"Dokonano losowania wśród ({String.Join(", ", users.Select(u => u.Name))})."));
            }
        }
Esempio n. 3
0
        public async Task CanRemoveMyOrderItem()
        {
            // Arrange
            var user = fixture.Create <TestUser>();

            using (var conversation = BotClient.Instance.CreateConversation())
            {
                var supplierName = await supplierFixture.CreateSupplierAsync(conversation);

                await orderFixture.AddOrderItemAsync(conversation, supplierName, user : user);

                // Act
                var response = await CommandExecutor.ExecuteAndWaitForResponseAsync(
                    conversation,
                    "#usunMojeZam",
                    user);

                // Assert
                StringAssert.Contains("Usunięto pozycję", response);

                var listResponse = await CommandExecutor.ExecuteAndWaitForResponseAsync(
                    conversation,
                    $"#lista {supplierName}",
                    user);

                StringAssert.DoesNotContain(user.Name, listResponse);
            }
        }