public async Task Alias_IndexPostWithNeitherPasswordNorEmail_BadRequest()
        {
            using (IdentityWsDbContext ef = CreateEf()) {
                ef.Aliases.Add(new Alias {
                    EmailAddress = "*****@*****.**"
                });
                await ef.SaveChangesAsync();

                AliasesController patient = new AliasesController(ef, dummyLog, now, dummyRunner);

                AliasesController.IndexPostRequestBody body = new AliasesController.IndexPostRequestBody();
                IActionResult result = await patient.IndexPost("*****@*****.**", body);

                result.Should().BeOfType <BadRequestResult>($"exactly one of '{nameof(body.otherEmailAddress)}' or '{nameof(body.password)} is required'");
            }
        }
        public async Task Alias_IndexPostWithExistingEmail_Conflict()
        {
            using (IdentityWsDbContext ef = CreateEf()) {
                ef.Aliases.Add(new Alias {
                    EmailAddress = "*****@*****.**"
                });
                await ef.SaveChangesAsync();

                AliasesController patient = new AliasesController(ef, dummyLog, now, dummyRunner);

                IActionResult result = await patient.IndexPost("*****@*****.**", new AliasesController.IndexPostRequestBody
                {
                    password = "******"
                });

                result.Should().BeOfType <StatusCodeResult>().Which.StatusCode.Should().Be(StatusCodes.Status409Conflict,
                                                                                           "the alias exists in the database");
            }
        }
        public async Task Alias_IndexPostWithWrongOtherEmail_NotFound()
        {
            using (IdentityWsDbContext ef = CreateEf()) {
                ef.Aliases.Add(new Alias
                {
                    EmailAddress = "*****@*****.**"
                });
                await ef.SaveChangesAsync();

                AliasesController patient = new AliasesController(ef, dummyLog, now, dummyRunner);

                AliasesController.IndexPostRequestBody body = new AliasesController.IndexPostRequestBody
                {
                    otherEmailAddress = "*****@*****.**"
                };
                IActionResult result = await patient.IndexPost("*****@*****.**", body);

                result.Should().BeOfType <NotFoundResult>($"the '{nameof(body.otherEmailAddress)}' does not exist");
            }
        }
        public async Task Alias_IndexPostWithPassword_NoContentWithNewAliasAndBeing()
        {
            using (IdentityWsDbContext ef = CreateEf()) {
                ef.Aliases.Add(new Alias {
                    EmailAddress = "*****@*****.**"
                });
                await ef.SaveChangesAsync();

                AliasesController patient = new AliasesController(ef, dummyLog, now, dummyRunner);

                IActionResult result = await patient.IndexPost("*****@*****.**", new AliasesController.IndexPostRequestBody
                {
                    password = "******"
                });

                result.Should().BeOfType <NoContentResult>("a non-existing email address was supplied along with a password");
                ef.Aliases.Include(a => a.Being).Should().Contain(a => a.EmailAddress == "*****@*****.**", "a new alias should have been created")
                .Which.Being.Should().NotBeNull("a new being should have been created");
            }
        }
        public async Task Alias_IndexPostWithOtherEmail_NoContentWithNewAliasAndLinkedBeing()
        {
            using (IdentityWsDbContext ef = CreateEf()) {
                ef.Aliases.Add(new Alias
                {
                    EmailAddress = "*****@*****.**",
                    Being        = new Being()
                });
                await ef.SaveChangesAsync();

                AliasesController patient = new AliasesController(ef, dummyLog, now, dummyRunner);

                AliasesController.IndexPostRequestBody body = new AliasesController.IndexPostRequestBody
                {
                    otherEmailAddress = "*****@*****.**"
                };
                IActionResult result = await patient.IndexPost("*****@*****.**", body);

                result.Should().BeOfType <NoContentResult>("an existing email address (only) was supplied");
                ef.Aliases.Include(a => a.Being).Should().Contain(a => a.EmailAddress == "*****@*****.**", "a new alias should have been created")
                .Which.Being.Aliases.Should().HaveCount(2, "the new alias should have been linked to the existing being");
            }
        }