Esempio n. 1
0
        public async Task AsAdmin_Succeeds()
        {
            using var client = await _fixture.BuildClient();

            await _fixture.AuthorizeAsAdmin(client);

            var result = await client.PostAsJsonAsync(Routes.v1.Editions.Create, new CreateUseCase.Command()
            {
                Name      = "test2",
                StartDate = DateTime.Today.AddMonths(1),
                EndDate   = DateTime.Today.AddMonths(1).AddDays(7)
            });

            Assert.Equal(System.Net.HttpStatusCode.Created, result.StatusCode);
            Assert.Equal(Routes.v1.Editions.DetailsFor(2), result.Headers.Location.OriginalString);
        }
Esempio n. 2
0
        public async Task AsAdmin_ForExistingEdition_ReturnsDetails()
        {
            using var client = await _fixture.BuildClient();

            await _fixture.AuthorizeAsAdmin(client);

            var result = await client.GetAsync(Routes.v1.Editions.DetailsFor(1));

            Assert.Equal(System.Net.HttpStatusCode.OK, result.StatusCode);
            var edition = await result.Content.ReadAsAsync <EditionDetails>();

            Assert.Equal(1, edition.ID);
            Assert.True(edition.IsCurrent);
            Assert.Equal("test", edition.Name);
            Assert.Equal(NodaTime.LocalDate.FromDateTime(DateTime.Today), edition.StartDate);
            Assert.Equal(NodaTime.LocalDate.FromDateTime(DateTime.Today.AddDays(7)), edition.EndDate);
        }
Esempio n. 3
0
        public async Task AsAdmin_ReturnsSeededEdition()
        {
            using var client = await _fixture.BuildClient();

            await _fixture.AuthorizeAsAdmin(client);

            var result = await client.GetAsync(Routes.v1.Editions.Index);

            Assert.Equal(System.Net.HttpStatusCode.OK, result.StatusCode);
            var editions = await result.Content.ReadAsAsync <EditionSummary[]>();

            editions.Should().ContainEquivalentOf(new EditionSummary()
            {
                ID             = 1,
                Name           = "test",
                StartDate      = NodaTime.LocalDate.FromDateTime(DateTime.Today),
                EndDate        = NodaTime.LocalDate.FromDateTime(DateTime.Today).PlusDays(7),
                CanShowDetails = true
            });
        }