public void ShouldFireMediatorEventEachTimeWhenLanguageChanged()
        {
            // =====================================
            // Hint for css selector

            /*
             * By.css('.classname')          // get by class name
             * By.css('input[type=radio]')   // get input by type radio
             * By.css('.parent .child')      // get child who has a parent
             */

            // Take a look at the component text
            // var html = _component.Markup;

            // =====================================

            // All 3 languages in a RadzenSplitButton
            var elements = _component.FindAll(".rz-menuitem");

            elements.Should().NotBeNull();
            elements.Count.Should().Be(3);

            string[] expectedLanguages = { "en-US", "ru-RU", "de-DE" };
            for (int i = 0; i < 3; i++)
            {
                elements[i].Click();
                MediatorMock.Verify(m => m.Publish(
                                        It.Is <ChangeCurrentCultureMessage>(m => m.CultureName == expectedLanguages[0]),
                                        It.IsAny <CancellationToken>()), Times.Once);
            }
        }
Esempio n. 2
0
        public OrganisationControllerTestFixtures SetQueryException <TException>() where TException : Exception, new()
        {
            MediatorMock
            .Setup(m => m.SendAsync(It.IsAny <GetOrganisationQuery>()))
            .Throws <TException>();

            return(this);
        }
Esempio n. 3
0
        public AccountLegalEntityControllerTestFixtures SetQueryResponse(long forAccountLegalEntityId, GetAccountLegalEntityQueryResult sendQueryResult)
        {
            MediatorMock
            .Setup(m => m.Send(
                       It.Is <GetAccountLegalEntityQuery>(request => request.AccountLegalEntityId == forAccountLegalEntityId),
                       It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(sendQueryResult));

            return(this);
        }
            public void should_receive_request_and_send_response()
            {
                // Arrange
                MediatorMock
                .Setup(i => i.Send(It.IsAny <EmployeeReadQuery>(), default(CancellationToken)))
                .ReturnsAsync(AnyEmployeeResponse);

                // Act
                var result = EmployeeControllerUnderTest.Read(AnyEmployeeResponse.EmployeeId).Result;

                // Assert
                Assert.IsType <OkObjectResult>(result);
            }
            public void should_receive_request_and_delete_request()
            {
                // Arrange
                MediatorMock
                .Setup(i => i.Send(It.IsAny <EmployeeDeleteCommand>(), default(CancellationToken)))
                .ReturnsAsync(Unit.Value);

                // Act
                var result = EmployeeControllerUnderTest.Delete(AnyEmployeeResponse.EmployeeId).Result;

                // Assert
                Assert.IsType <OkResult>(result);
            }
Esempio n. 6
0
        public OrganisationControllerTestFixtures SetQueryResult(Organisation organisation)
        {
            var response = new GetOrganisationResponse
            {
                Organisation = organisation
            };

            MediatorMock
            .Setup(m => m.SendAsync(It.Is <GetOrganisationQuery>(goq => goq.OrganisationType == organisation.Type && goq.Identifier == organisation.Code)))
            .ReturnsAsync(() => response);

            return(this);
        }
        public void ShouldFireLoginMediatorEventWhenElementClicked(ComponentType componentType)
        {
            var targetElement = componentType switch
            {
                ComponentType.NavMenu => _navMenuElements[1],
                ComponentType.Index => _indexButtons[0],
                _ => throw new ArgumentOutOfRangeException(nameof(componentType), componentType, null)
            };

            targetElement.Click();

            MediatorMock.Verify(m => m.Publish(It.IsAny <LoginToWgMessage>(), It.IsAny <CancellationToken>()), Times.Once);
        }
        public void ShouldFireOpenClansSearchMediatorEventWhenElementClicked(ComponentType componentType)
        {
            var targetElement = componentType switch
            {
                ComponentType.NavMenu => _navMenuElements[3],
                ComponentType.Index => _indexButtons[2],
                _ => throw new ArgumentOutOfRangeException(nameof(componentType), componentType, null)
            };

            targetElement.Click();

            MediatorMock.Verify(m => m.Publish(
                                    It.Is <OpenSearchDialogMessage>(m => m.Type == DialogType.FindClan),
                                    It.IsAny <CancellationToken>()), Times.Once);
        }
    }
            public void should_receive_request_and_update_employee()
            {
                // Arrange
                EmployeeRequest inputRequest = new EmployeeRequest()
                {
                    Name    = "joe",
                    Address = "waterloo",
                    Email   = "*****@*****.**"
                };

                MediatorMock
                .Setup(i => i.Send(It.IsAny <EmployeeUpdateCommand>(), default(CancellationToken)))
                .ReturnsAsync(Unit.Value);

                // Act
                var result = EmployeeControllerUnderTest.Update(AnyEmployeeResponse.EmployeeId, inputRequest).Result;

                // Assert
                Assert.IsType <OkResult>(result);
            }
            public void should_receive_request_to_create_employee()
            {
                // Arrange
                var inputRequest = new EmployeeRequest()
                {
                    Name    = "joe",
                    Address = "wellington",
                    Email   = "*****@*****.**"
                };

                MediatorMock
                .Setup(i => i.Send(It.IsAny <EmployeeCreateCommand>(), default(CancellationToken)))
                .ReturnsAsync(employeeCommand);

                // Act
                var result = EmployeeControllerUnderTest.Create(inputRequest).Result;

                // Assert
                Assert.IsType <CreatedResult>(result);
            }
Esempio n. 11
0
        public AuthorizationControllerTestFixture SetCanAccessApprenticeshipToReturnTrue()
        {
            MediatorMock.Setup(x => x.Send(It.IsAny <CanAccessApprenticeshipQuery>(), It.IsAny <CancellationToken>())).ReturnsAsync(true);

            return(this);
        }