public void GetClientCatalogsEmptyContextNotFound()
        {
            using (var context = DbTestContext.GenerateEmptyContext())
                using (var controller = new ClientCatalogsController(context, _mapper))
                {
                    var result = controller.GetClientCatalogs();

                    Assert.IsType <NotFoundResult>(result);
                }
        }
        public async void GetClientCatalogWithIncorrectIdReturnsNotFound()
        {
            using (var context = DbTestContext.GenerateContextWithData())
                using (var controller = new ClientCatalogsController(context, _mapper))
                {
                    var result = await controller.GetClientCatalog(99);

                    Assert.IsType <NotFoundResult>(result);
                }
        }
        public async void DeleteClientCatalogModelStateErrorReturnsBadRequest()
        {
            using (var context = DbTestContext.GenerateContextWithData())
                using (var controller = new ClientCatalogsController(context, _mapper))
                {
                    controller.ModelState.AddModelError("an error", "some error");

                    var result = await controller.DeleteClientCatalog(1);

                    Assert.IsType <BadRequestObjectResult>(result);
                }
        }
        public async void PostMultipleClientCatalogsModelStateErrorReturnsBadRequest()
        {
            using (var context = DbTestContext.GenerateContextWithData())
                using (var controller = new ClientCatalogsController(context, _mapper))
                {
                    controller.ModelState.AddModelError("an error", "some error");
                    IEnumerable <ClientCatalogDto> ClientCatalogList = Enumerable.Range(11, 10).Select(i => GetTestClientCatalogDto(i));

                    var result = await controller.PostMultipleClientCatalogs(ClientCatalogList);

                    Assert.IsType <BadRequestObjectResult>(result);
                }
        }
        public async void PostMultipleClientCatalogsCorrectDataCreatesClientCatalogs()
        {
            using (var context = DbTestContext.GenerateContextWithData())
                using (var controller = new ClientCatalogsController(context, _mapper))
                {
                    IEnumerable <ClientCatalogDto> ClientCatalogList = Enumerable.Range(11, 10).Select(i => GetTestClientCatalogDto(i));

                    var result = await controller.PostMultipleClientCatalogs(ClientCatalogList);

                    Assert.NotNull(result);
                    Assert.IsType <CreatedAtActionResult>(result);
                }
        }
        public async void PostClientCatalogCorrectDataCreatesClientCatalog()
        {
            using (var context = DbTestContext.GenerateContextWithData())
                using (var controller = new ClientCatalogsController(context, _mapper))
                {
                    ClientCatalogDto p11 = GetTestClientCatalogDto(11);

                    var result = await controller.PostClientCatalog(p11);

                    Assert.NotNull(result);
                    var resultValue = Assert.IsType <CreatedAtActionResult>(result);
                }
        }
        public async void DeleteClientCatalogIdDeletesClientCatalog()
        {
            using (var context = DbTestContext.GenerateContextWithData())
                using (var controller = new ClientCatalogsController(context, _mapper))
                {
                    var result = await controller.DeleteClientCatalog(3);

                    ClientCatalogDto p3 = GetTestClientCatalogDto(3);

                    Assert.NotNull(result);
                    var okObjectResult = Assert.IsType <OkObjectResult>(result);
                    var resultValue    = okObjectResult.Value;
                    Assert.Equal(p3, resultValue);
                }
        }
        public async void GetClientCatalogByIdReturnsSingleClientCatalog()
        {
            using (var context = DbTestContext.GenerateContextWithData())
                using (var controller = new ClientCatalogsController(context, _mapper))
                {
                    var result = await controller.GetClientCatalog(3);

                    var okObjectResult = Assert.IsType <OkObjectResult>(result);
                    var resultValue    = okObjectResult.Value;

                    ClientCatalogDto p3 = GetTestClientCatalogDto(3);

                    Assert.NotNull(resultValue);
                    Assert.IsType <ClientCatalogDto>(resultValue);
                    ClientCatalogDto p = (ClientCatalogDto)resultValue;
                    Assert.True(p.Equals(p3));
                    Assert.True(p.Equals(p3, true));
                }
        }
        public void GetClientCatalogsReturnsListOfAuthors()
        {
            using (var context = DbTestContext.GenerateContextWithData())
                using (var controller = new ClientCatalogsController(context, _mapper))
                {
                    var result          = controller.GetClientCatalogs();
                    ClientCatalogDto p3 = GetTestClientCatalogDto(3);

                    var okObjectResult = Assert.IsType <OkObjectResult>(result);
                    var resultValue    = okObjectResult.Value;
                    Assert.IsAssignableFrom <IEnumerable <ClientCatalogDto> >(resultValue);
                    Assert.NotEmpty((IEnumerable <ClientCatalogDto>)resultValue);

                    IEnumerable <ClientCatalogDto> resultValueList = (IEnumerable <ClientCatalogDto>)resultValue;

                    Assert.Equal(10, resultValueList.Count());
                    ClientCatalogDto p = (ClientCatalogDto)resultValueList.Where(r => r.Id == 3).FirstOrDefault();
                    Assert.True(p.Equals(p3));
                    Assert.True(p.Equals(p3, true));
                }
        }