Exemple #1
0
        public async Task IfDateTooEarly_ValidateTestResultForEditDate_ReturnsEarliestDateErrorMessage(bool isEdit)
        {
            // Arrange
            const int notificationId      = Utilities.NOTIFICATION_WITH_MANUAL_TESTS;
            var       notificationSubPath = isEdit ? NotificationSubPaths.EditManualTestResult(10) : NotificationSubPaths.AddManualTestResult;
            var       url         = GetPathForId($"{notificationSubPath}", notificationId, null);
            var       initialPage = await Client.GetAsync(url);

            var initialDocument = await GetDocumentAsync(initialPage);

            var request = new DateValidationModel
            {
                Key   = "TestDate",
                Day   = "1",
                Month = "1",
                Year  = "1899"
            };
            const string handlerPath = "ValidateTestResultForEditDate";
            var          endpointUrl = $"{url}/{handlerPath}";

            // Act
            var response = await Client.SendVerificationPostAsync(
                initialPage,
                initialDocument,
                endpointUrl,
                request);

            // Assert
            var result = await response.Content.ReadAsStringAsync();

            Assert.Equal(ValidationMessages.DateValidityRangeStart("Test date", "01/01/2010"), result);
        }
Exemple #2
0
        public async Task PostDelete_ReturnsSuccessAndRemovesResult()
        {
            // Arrange
            const int notificationId = Utilities.NOTIFICATION_WITH_TREATMENT_EVENTS;
            var       url            = GetPathForId(NotificationSubPaths.EditTreatmentEvent(DELETE_TREATMENT_EVENT_ID), notificationId);
            var       document       = await GetDocumentForUrlAsync(url);

            // Act
            var formData = new Dictionary <string, string> {
            };
            var result   = await Client.SendPostFormWithData(document, formData, url, "Delete");

            // Assert
            result.AssertRedirectTo(GetPathForId(NotificationSubPaths.EditTreatmentEvents, notificationId));
            var treatmentEventsDocument = await GetDocumentForUrlAsync(GetRedirectLocation(result));

            Assert.Null(treatmentEventsDocument.GetElementById($"social-context-venue-{DELETE_TREATMENT_EVENT_ID}"));
        }
Exemple #3
0
        public async Task PostEditTreatmentEvent_ReturnsSuccessAndEditsResultInTable()
        {
            // Arrange
            const int    notificationId      = Utilities.NOTIFICATION_WITH_TREATMENT_EVENTS;
            const int    treatmentEventId    = EDIT_TREATMENT_EVENT_ID;
            var          dateTimeTargetValue = new DateTime(2015, 5, 5);
            const string noteTargetValue     = "I can see it in your eyes";

            var url      = GetPathForId(NotificationSubPaths.EditTreatmentEvent(treatmentEventId), notificationId);
            var document = await GetDocumentForUrlAsync(url);

            var preEditRow = document.QuerySelector($"#treatment-event-{EDIT_TREATMENT_EVENT_ID}");

            Assert.NotNull(preEditRow);
            Assert.DoesNotContain(noteTargetValue, preEditRow.TextContent);
            Assert.Contains(TreatmentEventType.TreatmentOutcome.GetDisplayName(), preEditRow.TextContent);

            // Act
            var formData = new Dictionary <string, string>
            {
                ["FormattedEventDate.Day"]            = dateTimeTargetValue.Day.ToString(),
                ["FormattedEventDate.Month"]          = dateTimeTargetValue.Month.ToString(),
                ["FormattedEventDate.Year"]           = dateTimeTargetValue.Year.ToString(),
                ["TreatmentEvent.TreatmentEventType"] = ((int)TreatmentEventType.TreatmentRestart).ToString(),
                ["TreatmentEvent.Note"] = noteTargetValue
            };
            var result = await Client.SendPostFormWithData(document, formData, url);

            // Assert
            result.AssertRedirectTo(GetPathForId(NotificationSubPaths.EditTreatmentEvents, notificationId));
            var treatmentEventsDocument = await GetDocumentForUrlAsync(GetRedirectLocation(result));

            var treatmentRestartWithNoteRow = treatmentEventsDocument.QuerySelector($"#treatment-event-{treatmentEventId}");

            Assert.NotNull(treatmentRestartWithNoteRow);
            var treatmentRestartTextContent = treatmentRestartWithNoteRow.TextContent;

            Assert.Contains(dateTimeTargetValue.ConvertToString(), treatmentRestartTextContent);
            Assert.Contains(noteTargetValue, treatmentRestartTextContent);
            Assert.Contains(TreatmentEventType.TreatmentRestart.GetDisplayName(), treatmentRestartTextContent);
        }