Beispiel #1
0
    public async Task EndpointInstance()
    {
        var context = new TestableEndpointInstance();

        await((IMessageSession)context).Send(new SendMessage {
            Property = "Value"
        });
        await Verify(context);
    }
Beispiel #2
0
        public async Task RunTestableEndpointInstance()
        {
            var context = new TestableEndpointInstance();

            await RunTestableMessageSessionInternal(context, CancellationToken.None);

            await context.Stop();

            Assert.AreEqual(true, context.EndpointStopped);
        }
    public async Task EndpointInstance()
    {
        var context = new TestableEndpointInstance();
        var session = (IMessageSession)context;
        await session.Send(
            new SendMessage
        {
            Property = "Value"
        });

        context.Extensions.Set("key", "value");
        await Verify(context);
    }
Beispiel #4
0
    public async Task ShouldSendMessage()
    {
        var endpointInstance = new TestableEndpointInstance();
        var handler          = new MyController(endpointInstance);

        await handler.HandleRequest()
        .ConfigureAwait(false);

        var sentMessages = endpointInstance.SentMessages;

        Assert.AreEqual(1, sentMessages.Length);
        Assert.IsInstanceOf <MyMessage>(sentMessages[0].Message);
    }
Beispiel #5
0
        public void HomeModule_Deezer_WhenPostNullModel_ReturnBadRequest()
        {
            var endpointInstance = new TestableEndpointInstance();

            var browser  = GetBrowser(endpointInstance, true);
            var response = browser.Post("/Home/Deezer");

            var result = response.Body.AsString().Deserialize <ValidationResult>();

            Assert.AreEqual("application/json", response.ContentType);
            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
            Assert.AreEqual(2, result.Errors.Count);
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual("NotEmptyValidator", result.Errors[0].ErrorCode);
            Assert.AreEqual("NotEmptyValidator", result.Errors[1].ErrorCode);
        }
        public void Setup()
        {
            _mockLogger = new Mock <ILogger <SubmissionSucceededServiceBusTrigger> >();
            _mockSubmissionSucceededDelayedImportService = new Mock <ISubmissionSucceededDelayedImportService>();
            _mockFunctionEndpoint = new TestableEndpointInstance();

            _sut = new SubmissionSucceededServiceBusTrigger(_mockSubmissionSucceededDelayedImportService.Object, _mockLogger.Object);

            _submissionSucceededEvent = new SubmissionJobSucceeded
            {
                Ukprn            = 27367481,
                CollectionPeriod = 1,
                AcademicYear     = 2021
            };

            _message = JsonConvert.SerializeObject(_submissionSucceededEvent);
        }
Beispiel #7
0
        public void HomeModule_Deezer_WhenPostModel_ReturnOk()
        {
            var endpointInstance = new TestableEndpointInstance();

            var browser  = GetBrowser(endpointInstance, true);
            var response = browser.Post("/Home/Deezer", context =>
            {
                context.JsonBody(new DeezerUserModel {
                    Id = 1, AccessToken = "12345"
                });
            });

            var result = response.Body.AsString();

            Assert.AreEqual("application/json", response.ContentType);
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.IsEmpty(result);
        }
Beispiel #8
0
        public void HomeModule_Index_ReturnOk()
        {
            var endpointInstance = new TestableEndpointInstance();

            var browser  = GetBrowser(endpointInstance);
            var response = browser.Get("/Home/Index", context => {
                context.HttpRequest();
            });

            Assert.AreEqual("text/html", response.ContentType);
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.AreEqual("Index", response.GetViewName());

            response
            .Body["#login"]
            .ShouldExistOnce()
            .And.ShouldContain("Login to deezer");
        }