Example #1
0
 public Task Should_Return_Bad_Request_When_Provided_Empty_Token_Async()
 {
     using (var fixture = new ApiTestFixture())
         return fixture.WithOwinServer(async (client) =>
         {
             var result = await client.PostAsync("/Runtime/Logs/ListFiles/1?token=", new StringContent(string.Empty));
             result.StatusCode.ShouldBe(HttpStatusCode.BadRequest);
         });
 }
Example #2
0
            public Task Should_Succeed_Async()
            {
                using (var fixture = new ApiTestFixture())
                    return fixture.WithOwinServer(async (client) =>
                    {
                        var result = await client.PostAsync("/Runtime/Logs/ListFiles/1?token=" + Guid.NewGuid().ToString().ToLower(), new StringContent(string.Empty));

                        result.StatusCode.ShouldBe(HttpStatusCode.OK);
                        A.CallTo(() => fixture.ListLogsDirector.Initiate(A<string>.Ignored, A<DomainModel.Request<DomainModel.Empty>>.Ignored)).MustHaveHappened(Repeated.Exactly.Once);
                    });
            }
Example #3
0
            public Task Should_Return_ServiceUnavailable_StatusCode_Async()
            {
                using (var fixture = new ApiTestFixture())
                {
                    TaskCompletionSource<DomainModel.Response<IEnumerable<string>>> tsc = new TaskCompletionSource<DomainModel.Response<IEnumerable<string>>>();
                    tsc.SetException(new RuntimeHasNotConnectedException());

                    A.CallTo(() => fixture.ListLogsDirector.PendingTask)
                        .Returns(tsc.Task);

                    return fixture.WithOwinServer(async (client) =>
                    {
                        var result = await client.PostAsync("/Runtime/Logs/ListFiles/1?token=" + Guid.NewGuid().ToString().ToLower(), new StringContent(string.Empty));
                        result.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable);
                    });
                }
            }
Example #4
0
 public ToDoControllerShould(ApiTestFixture fixture) =>
Example #5
0
            public Task Should_Return_Timeout_StatusCode_Async()
            {
                using (var fixture = new ApiTestFixture())
                {
                    TaskCompletionSource<DomainModel.Response<byte[]>> tsc = new TaskCompletionSource<DomainModel.Response<byte[]>>();
                    tsc.SetException(new TimeoutException());

                    A.CallTo(() => fixture.OpenLogFileDirector.PendingTask)
                        .Returns(tsc.Task);

                    return fixture.WithOwinServer(async (client) =>
                    {
                        var result = await client.PostAsync("/runtime/Logs/OpenLog/1?token=" + Guid.NewGuid().ToString().ToLower(), new StringContent(string.Empty));
                        result.StatusCode.ShouldBe(HttpStatusCode.RequestTimeout);
                    });
                }
            }
Example #6
0
 public ValuesTests(ApiTestFixture fixture)
 {
     _client = fixture.Client;
 }