Пример #1
0
        public async Task Can_EditBlueprint()
        {
            ExecutorStub.StubResult(Agreements.FindBlueprint);
            ExecutorStub.StubResult(Agreements.Edit);

            var client = MvcTestingClient();

            var getResponse = await client
                              .GetAsync(Actions.Edit(123));

            var model = getResponse.ViewResultModel <StartEditModel>();

            model.Title.Should().Be("Edit Blueprint");
            model.ButtonText.Should().Be("Update");

            var form = getResponse.Form <StartEditCommand>();

            form.GetText(m => m.Name).Should().Be("TestBlueprint");

            var response = await form
                           .SetText(m => m.Name, "UpdatedBlueprint")
                           .Submit();

            ExecutorStub.VerifySingleExecuted(Agreements.Edit);
        }
Пример #2
0
        public async Task CanSeeListOfBlueprints()
        {
            ExecutorStub.StubResult(Agreements.FindBlueprints);

            var response = await MvcTestingClient()
                           .GetAsync(Actions.List());

            ExecutorStub.VerifySingleExecuted(Agreements.FindBlueprints);

            response.Doc.Find(".blueprintList").Should().NotBeNull();
            response.Doc.FindAll(".blueprintItem").Count.Should().Be(2);
            response.Doc.Find(".blueprintItem:nth-child(1) a").Attribute("href").Should().StartWith(Actions.Edit(101));
        }
Пример #3
0
        public async Task Login_RedirectsToOriginalPage()
        {
            ExecutorStub.StubResult(Agreements.Login);

            var action = Actions.Login() + $"/?returnUrl={HttpUtility.UrlEncode("http://someUrl")}";

            var form = await MvcTestingClient()
                       .GetAsync(action)
                       .Form <LoginCommand>();

            var response = await form
                           .SetText(m => m.UserName, "User1")
                           .Submit();

            response.ActionResultOf <RedirectResult>().Url.Should().Be("http://someUrl");
        }
Пример #4
0
        public async Task Can_StartCycle()
        {
            ExecutorStub.StubResult <StartCycleCommand>(123);

            var client = Client();

            var getResponse = await client
                              .GetAsync("/appFactory/manufacturing/cycles/start");

            var response = await getResponse.Form <StartCycleCommand>()
                           .SetText("Quantity", "123")
                           .Submit();

            response.Should().NotBeNull();

            ExecutorStub.SingleExecuted <StartCycleCommand>().Should().BeEquivalentTo(new StartCycleCommand
            {
                BlueprintId = -1,
                Quantity    = 123,
            });
        }
Пример #5
0
        public async Task Can_Login()
        {
            ExecutorStub.StubResult(Agreements.Login);

            var client = MvcTestingClient();

            var form = await client
                       .GetAsync(Actions.Login())
                       .Form <LoginCommand>();

            var response = await form
                           .SetText(m => m.UserName, "TestUser")
                           .Submit();

            ExecutorStub.VerifySingleExecuted(Agreements.Login);

            client.Cookies.Select(c => c.Name).Should().Contain(ModuleTestSetup.TestStartup.AuthCookieName);

            var redirectUrl = response.ActionResultOf <RedirectResult>().Url;

            redirectUrl.Should().Be("/");
        }
Пример #6
0
        public async Task Can_DownloadProjectZipFile()
        {
            var expectedByteString = "stub bytes";

            ExecutorStub.StubResult <GenerateProjectCommand>(Encoding.ASCII.GetBytes(expectedByteString));

            var form = await MvcTestingClient()
                       .GetAsync(Actions.Index())
                       .Form <GenerateProjectCommand>();

            var response = await form
                           .SetText(m => m.Name, "NewProj_1")
                           .Submit(r => r.SetExpectedResponse(HttpStatusCode.OK));

            ExecutorStub.VerifySingleExecuted(Agreements.GenerateProject);

            var fileResult = response.ActionResultOf <FileResult>();

            fileResult.ContentType.Should().Be("application/zip");
            fileResult.FileDownloadName.Should().Be("NewProj_1.zip");

            response.Text.Should().Be(expectedByteString);
        }