Example #1
0
        public async Task NonexistentBrother_ReturnsNotFound()
        {
            BrotherController controller = new BrotherController(_dbContext, null, null);
            IActionResult     result     = await controller.GetBrother(-1);

            Assert.Multiple(() => {
                Assert.That(result, Is.InstanceOf <NotFoundResult>());
                Assert.That((result as NotFoundResult)?.StatusCode, Is.EqualTo(StatusCodes.Status404NotFound));
            });
        }
Example #2
0
        public async Task ActiveBrother_IsReturned()
        {
            int id = _dbContext.Brother.Add(new Brother {
                FirstName = "First", LastName = "Last"
            }).Entity.Id;
            await _dbContext.SaveChangesAsync();

            BrotherController  controller = new BrotherController(_dbContext, null, null);
            BrotherDetailModel result     = ((OkObjectResult)await controller.GetBrother(id)).Value as BrotherDetailModel;

            Assert.Multiple(() => {
                Assert.That(result, Is.Not.Null);
                Assert.That(result.Id, Is.EqualTo(id));
                Assert.That(result.FirstName, Is.EqualTo("First"));
                Assert.That(result.LastName, Is.EqualTo("Last"));
            });
        }