public void WhenIOpenTheDetailsOfBook(string bookId) { var book = ReferenceBooks.GetById(bookId); var controller = new CatalogController(); actionResult = controller.Details(book.Id); }
public Bind() { Routes.MapHttpRoute("create_binding", "v2/service_instances/{instanceId}/service_bindings/{bindingId}"); var catalog = new Catalog(Substitute.For<IDatabaseBuilder>()); service = Substitute.For<ICloudFoundryService>(); serviceId = Guid.NewGuid(); catalog.Services.Add(serviceId.ToString(), service); controller = new CatalogController(catalog); }
public void DetailsReturnsCorrectView() { //arrange const int expectedProductId = 1; const decimal expectedPrice = 10m; var expectedProductName = "Mock Product-" + expectedProductId; var expectedBrandName = "Mock Brand For Product-" + expectedProductId; var expectedImageUrl = "Mock Image Url For Product-" + expectedProductId; var expectedSectionName = "Mock Section Name For Product-" + expectedProductId; var productDataMock = new Mock <IProductData>(); productDataMock.Setup(repo => repo.GetProductById(It.IsAny <int>())) .Returns <int>(id => new ProductDto( id, expectedProductName, 1, expectedPrice, expectedImageUrl, new BrandDto(1, expectedBrandName, 1, 1), new SectionDto(1, expectedSectionName, 1, null, 1) )); var configurationMock = new Mock <IConfiguration>(); configurationMock.Setup(configuration => configuration[It.IsAny <string>()]).Returns("12"); var controller = new CatalogController(productDataMock.Object, configurationMock.Object); //act var result = controller.Details(expectedProductId); //assert var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <ProductViewModel>(viewResult.Model); Assert.Equal(expectedProductId, model.Id); Assert.Equal(expectedProductName, model.Name); Assert.Equal(expectedPrice, model.Price); Assert.Equal(expectedImageUrl, model.ImageUrl); Assert.Equal(expectedBrandName, model.Brand.Name); Assert.Equal(expectedProductName, model.Name); }
public void TestLinqSearch() { var app = Startup.BooksApp; var session = app.OpenSession(); //We use catalog controller's SearchBooks method to invoke search method. // This is also a demo of using Api controllers outside Web server environment var contr = new CatalogController(app.CreateSystemContext()); //User search helper method with all possible search terms. Let's find c# book var searchParams = new BookSearch() { Title = "C#", Categories = "Programming,Fiction", MaxPrice = 100.0, Publisher = "MS", PublishedAfter = new DateTime(2000, 1, 1), PublishedBefore = DateTime.Now, AuthorLastName = "Sharp", OrderBy = "Price-desc,pubname,PublishedOn-desc", Skip = 0, Take = 5 }; var bookResults = contr.SearchBooks(searchParams); //PrintLastSql(session); Assert.AreEqual(1, bookResults.Results.Count, "Failed to find c# book"); /* Here's the resulting SQL for MS SQL 2012: * * SELECT f$.[Id], f$.[Title], f$.[Description], f$.[PublishedOn], f$.[Abstract], f$.[Category], f$.[Editions], f$.[Price], * f$.[CreatedIn], f$.[UpdatedIn], f$.[Publisher_Id] * FROM [books].[Book] f$, [books].[Publisher] t1$ * WHERE (t1$.[Id] = f$.[Publisher_Id]) AND ((f$.[Title] LIKE @P5 ESCAPE '\') AND * (f$.[Price] <= @P0) AND (t1$.[Name] LIKE @P6 ESCAPE '\') AND * (f$.[PublishedOn] >= @P1) AND * (f$.[PublishedOn] <= @P2) AND * f$.[Category] IN (0, 1) AND * (f$.[Id] IN (SELECT ba$.[Book_Id] * FROM [books].[BookAuthor] ba$, [books].[Author] t2$ * WHERE (t2$.[Id] = ba$.[Author_Id]) AND (t2$.[LastName] LIKE @P7 ESCAPE '\')))) * ORDER BY f$.[Price] DESC, t1$.[Name], f$.[PublishedOn] DESC * OFFSET @P3 ROWS FETCH NEXT @P4 ROWS ONLY * -- Parameters: @P0=100, @P1=[2000-01-01T00:00:00], @P2=[2015-02-28T02:05:42], @P3=0, @P4=5, @P5='c#%', @P6='MS%', @P7='Sharp%' */ // run with empty terms, 'get-any-top-10' searchParams = new BookSearch() { Take = 10 }; bookResults = contr.SearchBooks(searchParams); Assert.IsTrue(bookResults.Results.Count > 3, "Must return all books"); }
public void ProductDetails_Returns_NotFound() { // Arrange var productMock = new Mock <IProductService>(); productMock .Setup(p => p.GetProductById(It.IsAny <int>())) .Returns((ProductDto)null); var configMock = new Mock <IConfiguration>(); var controller = new CatalogController(productMock.Object, configMock.Object); // Act var result = controller.ProductDetails(1); // Assert Xunit.Assert.IsType <NotFoundResult>(result); }
public void Details_Returns_NotFound_if_Product_not_Exist() { const int expected_product_id = 1; var product_data_mock = new Mock <IProductService>(); product_data_mock .Setup(p => p.GetProductById(It.IsAny <int>())) .Returns(default(ProductDTO)); var config_mock = new Mock <IConfiguration>(); var controller = new CatalogController(product_data_mock.Object, config_mock.Object); var result = controller.ProductDetails(expected_product_id); Assert.IsType <NotFoundResult>(result); }
public async Task CatalogIndex() { // Arrange CatalogController controller = new CatalogController(catalogService.Object, settingsService.Object); // Act ViewResult result = await controller.Index(null) as ViewResult; // Assert IPagedList <Product> pagedList = result.Model as IPagedList <Product>; Assert.IsNotNull(pagedList); Assert.AreEqual(pageSize, pagedList.Count); Assert.AreEqual(Math.Ceiling((float)totalProducts / (float)pageSize), pagedList.PageCount); Assert.AreEqual(1, pagedList.PageNumber); Assert.AreEqual(totalProducts, pagedList.TotalItemCount); }
public MainWindowViewModel() { CatalogController = new CatalogController(); this.CloseCommand = new RelayCommand(this.CloseCommandExecute); this.VehicleSearchViewModel = new VehicleSearchViewModel(); this.shoppingBasketContent = new ShoppingBasketViewModel(); this.Contents = new ObservableCollection <ITMCatalogContent>(); this.Contents.Add(vehicleSearchViewModel); this.Contents.Add(shoppingBasketContent); this.SelectedContent = vehicleSearchViewModel; Instance = this; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_ClickGroup(object sender, DirectEventArgs e) { if (string.IsNullOrEmpty(hdfGroup.Text)) { Dialog.ShowError("Bạn chưa chọn loại danh mục"); return; } var model = new CatalogModel(hdfTableDM.Text) { Name = txtTenDMGroup.Text, Group = hdfGroup.Text }; CatalogController.Create(hdfCurrentCatalogName.Text, model); RM.RegisterClientScriptBlock("add", "resetInputCategoryGroup();"); grpCategoryGroup.Reload(); }
public void SetUserProfile(UserProfile userProfile) { Assert.IsTrue(userProfile != null, "userProfile can't be null"); currentUserProfile = userProfile; name.text = currentUserProfile.userName; description.text = currentUserProfile.description; avatarPicture.texture = currentUserProfile.faceSnapshot; ClearCollectibles(); CatalogController.RequestOwnedWearables(userProfile.userId) .Then((ownedWearables) => { currentUserProfile.SetInventory(ownedWearables.Select(x => x.id).ToArray()); loadedWearables.AddRange(ownedWearables.Select(x => x.id)); var collectiblesIds = currentUserProfile.GetInventoryItemsIds(); for (int index = 0; index < collectiblesIds.Length; index++) { string collectibleId = collectiblesIds[index]; CatalogController.wearableCatalog.TryGetValue(collectibleId, out WearableItem collectible); if (collectible == null) { continue; } var playerInfoCollectible = collectiblesFactory.Instantiate <PlayerInfoCollectibleItem>(collectible.rarity, wearablesContainer.transform); if (playerInfoCollectible == null) { continue; } playerInfoCollectibles.Add(playerInfoCollectible); playerInfoCollectible.Initialize(collectible); } emptyCollectiblesImage.SetActive(collectiblesIds.Length == 0); }) .Catch((error) => Debug.Log(error)); SetIsBlocked(IsBlocked(userProfile.userId)); UpdateFriendButton(); }
public void Shop_Method_Returns_Correct_View() { var productMock = new Mock <IProductData>(); productMock.Setup(p => p.GetProducts(It.IsAny <ProiductFilter>())).Returns(new List <ProductDto>() { new ProductDto() { Id = 1, Name = "Test", ImageUrl = "TestImage.jpg", Order = 0, Price = 10, Brand = new BrandDto() { Id = 1, Name = "TestBrand" } }, new ProductDto() { Id = 2, Name = "Test2", ImageUrl = "TestImage2.jpg", Order = 1, Price = 22, Brand = new BrandDto() { Id = 1, Name = "TestBrand" } } }); var controller = new CatalogController(productMock.Object); var result = controller.Shop(1, 5); var viewResult = Xunit.Assert.IsType <ViewResult>(result); var model = Xunit.Assert.IsAssignableFrom <CatalogViewModel>( viewResult.ViewData.Model); Xunit.Assert.Equal(2, model.Products.Count()); Xunit.Assert.Equal(5, model.BrandId); Xunit.Assert.Equal(1, model.SectionId); Xunit.Assert.Equal("TestImage2.jpg", model.Products.ToList()[1].ImageUrl); }
protected void Page_Load(object sender, EventArgs e) { if (!ExtNet.IsAjaxRequest) { // init department storeDepartment.DataSource = CurrentUser.DepartmentsTree; storeDepartment.DataBind(); // init employee type storeEmployeeType.DataSource = CatalogController.GetAll("cat_EmployeeType", null, null, null, false, null, null); storeEmployeeType.DataBind(); //init generate employeeCode txtEmployeeCode.Text = GenerateEmployeeCode(); wdEmployeeShort.Show(); } }
public void ProductDetails_Returns_View_With_Correct_Item() { const int expected_id = 15; const int expected_brand_id = 10; const string expected_name = "Product name"; const int expected_order = 1; const decimal excpected_price = 11; const string expected_image_url = "image.jpg"; const string expected_brand_name = "Brand name"; var product_data_mock = new Mock <IProductData>(); product_data_mock .Setup(p => p.GetProductById(It.IsAny <int>())) .Returns <int>(id => new ProductDTO { Id = id, Name = expected_name, Order = expected_order, Price = excpected_price, ImageUrl = expected_image_url, Brand = new BrandDTO { Id = expected_brand_id, Name = expected_brand_name } }); var configuration_mock = new Mock <IConfiguration>(); var catalog_controller = new CatalogController(product_data_mock.Object, configuration_mock.Object); var result = catalog_controller.ProductDetails(expected_id); var view_result = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <ProductViewModel>(view_result.ViewData.Model); Assert.Equal(expected_id, model.Id); Assert.Equal(expected_name, model.Name); Assert.Equal(expected_order, model.Order); Assert.Equal(excpected_price, model.Price); Assert.Equal(expected_image_url, model.ImageUrl); Assert.Equal(expected_brand_name, model.Brand); }
public void Details_Returns_With_Correct_View() { const int expected_product_id = 1; const decimal expected_price = 10m; var expected_name = $"Product id {expected_product_id}"; var expected_brand_name = $"Brand of product {expected_product_id}"; var product_data_mock = new Mock <IProductData>(); product_data_mock .Setup(p => p.GetProductById(It.IsAny <int>())) .Returns <int>(id => new ProductDTO { Id = id, Name = $"Product id {id}", ImageUrl = $"Image_id_{id}.png", Order = 1, Price = expected_price, Brand = new BrandDTO { Id = 1, Name = $"Brand of product {id}" }, Section = new SectionDTO { Id = 1, Name = $"Section of product {id}" } }); var config_mock = new Mock <IConfiguration>(); var controller = new CatalogController(product_data_mock.Object, config_mock.Object); var result = controller.Details(expected_product_id); var view_result = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <ProductViewModel>(view_result.Model); Assert.Equal(expected_product_id, model.Id); Assert.Equal(expected_name, model.Name); Assert.Equal(expected_price, model.Price); Assert.Equal(expected_brand_name, model.Brand); }
public IEnumerator FailGracefullyWhenIdsCannotBeResolved() { var wearablePromise1 = CatalogController.RequestWearable("Invalid_id"); var wearablePromise2 = CatalogController.RequestWearable("Scioli_right_arm"); var wearablePromise3 = CatalogController.RequestWearable("Peron_hands"); yield return(wearablePromise1); Assert.AreEqual("The request for the wearable 'Invalid_id' has exceed the set timeout!", wearablePromise1.error); yield return(wearablePromise2); Assert.AreEqual("The request for the wearable 'Scioli_right_arm' has exceed the set timeout!", wearablePromise2.error); yield return(wearablePromise3); Assert.AreEqual("The request for the wearable 'Peron_hands' has exceed the set timeout!", wearablePromise3.error); }
public void DetailsViewProductNotFound() { var expectedProductId = 1; var productDataMock = new Mock <IProductData>(); var configMock = new Mock <IConfiguration>(); productDataMock .Setup(p => p.GetProductById(It.IsAny <int>())) .Returns(default(ProductDTO)); var controller = new CatalogController(productDataMock.Object, configMock.Object); var result = controller.Details(expectedProductId); var viewResult = Assert.IsType <NotFoundResult>(result); }
public void DetailAction_CheckIfReturnsCorrectDetailsOfACatalog_ReturnsPropertyOfAnyLibraryAsset() { //arrange var libraryAssetService = new Mock <ILibraryAsset>(); var checkoutService = new Mock <ICheckout>(); libraryAssetService.Setup(asset => asset.GetById(233)).Returns(TestHelper.LibraryAsset()); var _controller = new CatalogController(libraryAssetService.Object, checkoutService.Object); //act var libraryAsset = _controller.Detail(233); //assert var viewResult = Assert.IsType <ViewResult>(libraryAsset); var model = Assert.IsType <AssetDetailModel>(viewResult.ViewData.Model); Assert.Equal(233, model.AssetId); }
public async Task Get_catalog_item_notfound() { //Arrange var dbOptions = new DbContextOptionsBuilder <CatalogContext>() .UseInMemoryDatabase(databaseName: $"{VersionPrefix}{nameof(Get_catalog_item_notfound)}") .Options; using var dbContext = new CatalogContext(dbOptions); dbContext.AddRange(GetFakeCatalog(1)); dbContext.SaveChanges(); //Act var orderController = new CatalogController(dbContext, mapper); var actionResult = await orderController.ItemByIdAsync(2); //Assert Assert.IsType <NotFoundResult>(actionResult.Result); }
public void GetAllCheckoutTest() { //arrange var MockLibraryRepo = new Mock <ILibraryAssetService>(); var MockcheckoutRepo = new Mock <ICheckOutService>(); MockcheckoutRepo.Setup(r => r.GetAll()).Returns(GetAllCheckout()); var controller = new CatalogController(MockLibraryRepo.Object, MockcheckoutRepo.Object); //act var result = controller.CheckOutHistory(); //assert var resultView = Assert.IsType <ViewResult>(result); var resultModel = Assert.IsType <CheckOutIndexModel>(resultView.ViewData.Model); Assert.Equal(3, resultModel.checkOutHistoryModel.Count()); }
public void Details_Returns_NotFound_if_Product_not_Exists() { var logger_mock = new Mock <ILogger <CatalogController> >(); var product_data_mock = new Mock <IProductData>(); product_data_mock .Setup(p => p.GetProductById(It.IsAny <int>())) .Returns(default(ProductDTO)); var config_mock = new Mock <IConfiguration>(); var controller = new CatalogController(product_data_mock.Object, config_mock.Object); var result = controller.Details(1, logger_mock.Object); Assert.IsType <NotFoundResult>(result); }
public void Should_Return_AllLibraryAsset() { var mockLibraryAssetService = new Mock <ILibraryAsset>(); var mockCheckoutService = new Mock <ICheckOut>(); mockLibraryAssetService.Setup(r => r.GetAll()).Returns(GetAllAssets()); var controller = new CatalogController(mockLibraryAssetService.Object, mockCheckoutService.Object); var result = controller.Index(); var viewResult = result.Should().BeOfType <ViewResult>(); viewResult.Subject.Model.Should().BeOfType <AssetIndexViewModel>(); var viewmodel = viewResult.Subject.Model.Should().BeAssignableTo <AssetIndexViewModel>(); viewmodel.Subject.Assets.Count().Should().Be(2); mockLibraryAssetService.Verify(x => x.GetAll(), Times.Once()); }
private async void button1_Click(object sender, EventArgs e) { string catalogName = tbCatalogName.Text; bool isValid = true; if (string.IsNullOrWhiteSpace(catalogName)) { errorProvider.SetError(tbCatalogName, "Bat buoc"); isValid = false; } else { errorProvider.SetError(tbCatalogName, null); } if (!isValid) { return; } var res = await CatalogController.UpdateCatalog( _catalogListPage.CurrentEditingCatalog.Id, new Catalog { CatalogName = catalogName, }); if (res == null) { return; } if (!res.IsSuccess) { Notification.Error(HandleError <CatalogErrorMessage> .GetErrorString(res.Messages)); return; } Notification.Success("Success"); _catalogListPage.renderCatalogs(); this.Hide(); }
public void Details_Returns_with_Correct_View() { #region Arrange const int expected_product_id = 1; const decimal expected_price = 10m; var expected_name = $"Product id {expected_product_id}"; var expected_brand_name = $"Brand of product {expected_product_id}"; var product_data_mock = new Mock <IProductData>(); product_data_mock.Setup(p => p.GetProductById(It.IsAny <int>())) .Returns <int>(id => new ProductDTO( id, $"Product id {id}", 1, expected_price, $"img{id}.png", new BrandDTO(1, $"Brand of product {id}", 1, 1), new SectionDTO(1, $"Section of product {id}", 1, null, 1) )); var controller = new CatalogController(product_data_mock.Object); #endregion #region Act var result = controller.Details(expected_product_id); #endregion #region Assert var view_result = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <ProductViewModel>(view_result.Model); Assert.Equal(expected_product_id, model.Id); Assert.Equal(expected_name, model.Name); Assert.Equal(expected_price, model.Price); Assert.Equal(expected_brand_name, model.Brand); #endregion }
public void Should_Return_Detail_LibraryAsset() { //Arrange var mockLibraryAssetService = new Mock <ILibraryAsset>(); var mockCheckoutService = new Mock <ICheckOut>(); mockLibraryAssetService.Setup(r => r.GetById(23)).Returns(GetAsset()); mockCheckoutService.Setup(r => r.GetCurrentHoldPlaced(23)).Returns(GetCurrentHold().HoldPlaced); mockCheckoutService.Setup(r => r.GetCurrentHoldPatron(23)).Returns(GetCurrentHold().PatronName); mockCheckoutService.Setup(r => r.GetCheckoutHistory(23)).Returns(new List <CheckoutHistory> { new CheckoutHistory() }); mockLibraryAssetService.Setup(r => r.GetType(23)).Returns("Book"); mockLibraryAssetService.Setup(r => r.GetCurrentLocation(23)).Returns(new LibraryBranch { Name = "Hawkins Library" }); mockLibraryAssetService.Setup(r => r.GetAuthorOrDirector(23)).Returns("Virginia Woolf"); mockLibraryAssetService.Setup(r => r.GetDeweyIndex(23)).Returns("ELEVEN"); mockCheckoutService.Setup(r => r.GetCheckoutHistory(23)).Returns(new List <CheckoutHistory> { new CheckoutHistory() }); mockCheckoutService.Setup(r => r.GetLatestCheckout(23)).Returns(new Checkouts()); mockCheckoutService.Setup(r => r.GetCurrentPatron(23)).Returns("NANCY"); var sut = new CatalogController(mockLibraryAssetService.Object, mockCheckoutService.Object); var result = sut.Detail(23); var viewResult = result.Should().BeOfType <ViewResult>(); var viewModel = viewResult.Subject.ViewData.Model.Should().BeAssignableTo <AssetDetailViewModel>(); viewModel.Subject.Title.Should().Be("Cameroon"); viewModel.Subject.Type.Should().Be("Book"); viewModel.Subject.AuthorOrDirector.Should().Be("Virginia Woolf"); viewModel.Subject.CurrentLocation.Should().Be("Hawkins Library"); viewModel.Subject.DeweyCallNumber.Should().Be("ELEVEN"); viewModel.Subject.PatronName.Should().Be("NANCY"); }
public void CleanupAvatar() { StopLoadingCoroutines(); eyebrowsController?.CleanUp(); eyebrowsController = null; eyesController?.CleanUp(); eyesController = null; mouthController?.CleanUp(); mouthController = null; bodyShapeController?.CleanUp(); bodyShapeController = null; using (var iterator = wearableControllers.GetEnumerator()) { while (iterator.MoveNext()) { iterator.Current.Value.CleanUp(); } } wearableControllers.Clear(); model = null; isLoading = false; OnFailEvent = null; OnSuccessEvent = null; if (lodController != null) { Environment.i.platform.avatarsLODController.RemoveAvatar(lodController); } if (bodySnapshotTexturePromise != null) { AssetPromiseKeeper_Texture.i.Forget(bodySnapshotTexturePromise); } CatalogController.RemoveWearablesInUse(wearablesInUse); wearablesInUse.Clear(); OnVisualCue?.Invoke(VisualCue.CleanedUp); }
public async Task Put_catalog_item_description_notfound() { //Arrange var dbOptions = new DbContextOptionsBuilder <CatalogContext>() .UseInMemoryDatabase(databaseName: $"{VersionPrefix}{nameof(Put_catalog_item_description_notfound)}") .Options; using var dbContext = new CatalogContext(dbOptions); dbContext.AddRange(GetFakeCatalog(2)); dbContext.SaveChanges(); var newDescription = "Updated description"; //Act var orderController = new CatalogController(dbContext, mapper); var actionResult = await orderController.UpdateProductAsync(3, newDescription); //Assert Assert.IsType <NotFoundObjectResult>(actionResult); }
internal static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (args.Contains("--nodb")) { var CatalogController = new CatalogController(); Application.Run(CatalogController.RenderMainView()); } else { using (var db = new DatabaseContext()) { var CatalogController = new CatalogController(db); Application.Run(CatalogController.RenderMainView()); } } }
[Fact] public void IndexAction_CheckIfReturnsCorrectListofCatalog_ReturnsAllLibraryAsset() { //arrange var libraryAssetService = new Mock <ILibraryAsset>(); var checkoutService = new Mock <ICheckout>(); libraryAssetService.Setup(a => a.GetAll()).Returns(TestHelper.LibraryAssets()); var _controller = new CatalogController(libraryAssetService.Object, checkoutService.Object); //act var libraryAssetList = _controller.Index(); //assert var viewResult = Assert.IsType <ViewResult>(libraryAssetList); var model = Assert.IsAssignableFrom <AssetIndexModel>(viewResult.ViewData.Model); var modelList = model.Assets; Assert.Equal(2, modelList.Count()); }
public void Should_Return_CheckOutViewModel_When_CheckOut_Called() { //Arrange var mockLibraryAsset = new Mock <ILibraryAsset>(); var mockCheckOut = new Mock <ICheckOut>(); mockLibraryAsset.Setup(x => x.GetById(23)).Returns(GetAsset()); var catalog = new CatalogController(mockLibraryAsset.Object, mockCheckOut.Object); //Act var result = catalog.Checkout(23); //Assert var viewresult = result.Should().BeOfType <ViewResult>(); var viewmodel = viewresult.Subject.ViewData.Model.Should().BeAssignableTo <CheckoutViewModel>(); viewmodel.Subject.AssetId.Should().Be(23); viewmodel.Subject.Title.Should().Be("Cameroon"); }
public void CheckOutAction_WhenValidIdPassed_ReturnsLibraryAssetObject() { //arrange var libraryAssetService = new Mock <ILibraryAsset>(); var checkoutService = new Mock <ICheckout>(); libraryAssetService.Setup(r => r.GetById(233)).Returns(TestHelper.LibraryAsset()); var _controller = new CatalogController(libraryAssetService.Object, checkoutService.Object); //act var checkoutModel = _controller.CheckOut(233); //assert var viewResult = Assert.IsType <ViewResult>(checkoutModel); var model = Assert.IsType <CheckoutModels>(viewResult.ViewData.Model); Assert.Equal(233, model.AssetId); Assert.Equal("Testing", model.Title); }
public async Task Index_Exception() { //arrange catalogServiceMock .Setup(s => s.GetProducts()) .ThrowsAsync(new Exception()); //act var catalogController = new CatalogController(catalogServiceMock.Object, loggerMock.Object, userRedisRepositoryMock.Object); var result = await catalogController.Index(); var model = result as IList <Product>; //assert Assert.Null(model); Assert.True(!string.IsNullOrWhiteSpace(catalogController.ViewBag.MsgServiceUnavailable)); }
private void CreateDropDownExcel(string obj, WorkBook workbook, DataColumn col) { var list = CatalogController.GetAll(obj, null, null, null, false, null, null); if (list == null) { return; } var validation = workbook.CreateDataValidation(); validation.Type = DataValidation.eUser; var validateList = "\"{0}\"".FormatWith(string.Join(",", list.Select(l => l.Name + " ({0})".FormatWith(l.Id)).ToList())); // formula string length cannot be greater than 256 if (validateList.Length < 256) { // set formula by string validation.Formula1 = validateList; } else { var columnName = GetExcelColumnName(col.Ordinal + 1); // select info sheet workbook.Sheet = 1; // write list into info sheet foreach (var item in list.Select((value, index) => new { value, index })) { workbook.setText(item.index + 1, col.Ordinal, item.value.Name + " ({0})".FormatWith(item.value.Id)); } // select workbook.Sheet = 0; // set formula by selected range validation.Formula1 = "Info!${0}$2:${0}${1}".FormatWith(columnName, list.Count); } // selection range workbook.setSelection(2, col.Ordinal, 50, col.Ordinal); // custom style selection var range = workbook.getRangeStyle(); range.CustomFormat = ""; //workbook.setRangeStyle(range); workbook.DataValidation = validation; }
public void WhenIPerformASimpleSearchOn(string searchTerm) { var controller = new CatalogController(); actionResult = controller.Search(searchTerm); }
public void ReturnsCatalogOfServices() { var catalog = new Catalog(Substitute.For<IDatabaseBuilder>()); var service = Substitute.For<ICloudFoundryService>(); var serviceId = Guid.NewGuid(); catalog.Services.Add(serviceId.ToString(), service); var controller = new CatalogController(catalog); IHttpActionResult result = controller.Get(); var response = result as OkNegotiatedContentResult<CatalogResponse>; Assert.NotNull(response); Assert.Equal(2, response.Content.Services.Count); }