public async Task CanCreateCustomer() { await sut.Execute(CommonDataSet.CustomerBindingModel); Assert.Equal(1, context.Object.Customers.Local.Count); context.Verify(x => x.SaveChangesAsync(), Times.Once()); }
public async Task ShouldInsertCustomerIntoDatabase() { var command = new CreateCustomerCommand(_context); var model = new CreateCustomerModel { Id = "FLYNN", CompanyName = "Flynn's Arcade", ContactName = "Kevin" }; await command.Execute(model); var entity = await _context.Customers.FindAsync("FLYNN"); Assert.NotNull(entity); }
private void PopulateTiles() { //customers:customer:create && (customers:case:view:all || customers:case:view:assigned) if (_authContext.CheckPermission(PredefinedPermissions.CustomersCreateCustomer)) { _tileManager.AddTile(new IconTileItem() { IdModule = NavigationNames.MenuName, IdTile = "NewCustomer", TileIconSource = "Icon_Module_Customers", TileTitle = "New customer", TileCategory = NavigationNames.ModuleName, Order = 0, IdColorSchema = TileColorSchemas.Schema1, NavigateCommand = new DelegateCommand(async() => { if (NavigateToTabPage(NavigationNames.HomeName)) { await Task.Run(() => Thread.Sleep(300)); // we need some time to parse xaml CreateCustomerCommand.Execute(); } }) }); } if (_authContext.CheckPermission(PredefinedPermissions.CustomersCreateNewCase)) { _tileManager.AddTile(new IconTileItem() { IdModule = NavigationNames.MenuName, IdTile = "NewEmailCase", TileIconSource = "Icon_New_Case", TileTitle = "New case", TileCategory = NavigationNames.ModuleName, Order = 1, IdColorSchema = TileColorSchemas.Schema2, NavigateCommand = new DelegateCommand(async() => { if (NavigateToTabPage(NavigationNames.HomeName)) { await Task.Run(() => Thread.Sleep(300)); // we need some time to parse xaml CreateNewCommerceManagerCase(new Contact(), ContactActionState.New, CaseActionState.New); } }) }); } if (_authContext.CheckPermission(PredefinedPermissions.Name_CustomersViewAssignedCases) || _authContext.CheckPermission(PredefinedPermissions.CustomersViewAllCasesAll)) { _tileManager.AddTile(new ListTileItem() { IdModule = NavigationNames.MenuName, IdTile = "Activity", TileTitle = "Activity", TileCategory = NavigationNames.ModuleName, Order = 3, IdColorSchema = TileColorSchemas.Schema3, NavigateCommand = new DelegateCommand(() => { }), Refresh = async(tileItem) => { var stringResult = await UpdateActivityTileOnShell(); var listTile = (ListTileItem)tileItem; listTile.InfoList = new ObservableCollection <string>(stringResult); } }); } if (_authContext.CheckPermission(PredefinedPermissions.Name_CustomersViewAssignedCases) || _authContext.CheckPermission(PredefinedPermissions.CustomersViewAllCasesAll)) { _tileManager.AddTile(new NumberTileItem() { IdModule = NavigationNames.MenuName, IdTile = "PendingCases", TileTitle = "Pending cases", TileCategory = NavigationNames.ModuleName, Order = 4, IdColorSchema = TileColorSchemas.Schema2, NavigateCommand = new DelegateCommand(() => NavigateToTabPage(NavigationNames.HomeName)), Refresh = async(tileItem) => { using (var repository = _customerRepository.GetRepositoryInstance()) { try { if (tileItem is NumberTileItem) { var query = await Task.Run( () => repository.Cases.Where(c => c.Status == CaseStatus.Pending.ToString()) .Count()); (tileItem as NumberTileItem).TileNumber = query.ToString(); } } catch { } } } }); } if (_authContext.CheckPermission(PredefinedPermissions.Name_CustomersViewAssignedCases) || _authContext.CheckPermission(PredefinedPermissions.CustomersViewAllCasesAll)) { _tileManager.AddTile(new ListTileItem() { IdModule = NavigationNames.MenuName, IdTile = "LastestCases", TileTitle = "Latest cases", TileCategory = NavigationNames.ModuleName, Order = 2, Width = (double)TileSize.Double, IdColorSchema = TileColorSchemas.Schema4, NavigateCommand = new DelegateCommand(() => { }), Refresh = async(tileItem) => { using (var repository = _customerRepository.GetRepositoryInstance()) { try { var currTile = tileItem as ListTileItem; if (currTile != null) { var query = await Task.Run(() => repository.Cases.OrderBy(x => x.Created).Take(4)); if (currTile.InfoList == null) { currTile.InfoList = new ObservableCollection <string>(); } currTile.InfoList.Clear(); foreach (var item in query) { currTile.InfoList.Add(item.Title); } } } catch { } } } }); } }