public async Task GetAsync2_ReturnsRecordWithId2() { //Assert //Act var result = await testedService.GetAsync(2); //Assert Assert.Equal(testEntities.ToArray()[2], result); }
public async Task GetAsync_SouldReturn_Null_IfCompanyDoNotExists() { var db = this.GetDatabase(); var mapper = this.GetMapper(); var firstCompany = new Company { Id = 1, Name = "Свеплина", Bulstat = "903097356", AccountablePerson = "H", Address = "k" }; var secondCompany = new Company { Id = 2, Name = "Просперитет", Bulstat = "BG909087356", AccountablePerson = "Y", Address = "ko" }; var thirdCompany = new Company { Id = 3, Name = "Тотал Щета", Bulstat = "903099066", AccountablePerson = "opk", Address = "top" }; await db.Companies.AddRangeAsync(firstCompany, secondCompany, thirdCompany); await db.SaveChangesAsync(); var companyService = new CompaniesService(db, mapper); var result = await companyService.GetAsync(4); result .Should() .BeNull(); }
public async Task GetAsync_SouldReturn_CorrectModel_IfCompanyExists() { var db = this.GetDatabase(); var mapper = this.GetMapper(); var firstCompany = new Company { Id = 1, Name = "Свеплина", Bulstat = "903097356", AccountablePerson = "H", Address = "k" }; var secondCompany = new Company { Id = 2, Name = "Просперитет", Bulstat = "BG909087356", AccountablePerson = "Y", Address = "ko" }; var thirdCompany = new Company { Id = 3, Name = "Тотал Щета", Bulstat = "903099066", AccountablePerson = "opk", Address = "top" }; await db.Companies.AddRangeAsync(firstCompany, secondCompany, thirdCompany); await db.SaveChangesAsync(); var companyService = new CompaniesService(db, mapper); var result = await companyService.GetAsync(2); result .Should() .BeOfType <CompanyDetailsModel>() .And .Match <CompanyDetailsModel>(c => c.AccountablePerson == "Y" && c.Address == "ko" && c.Bulstat == "BG909087356" && c.Name == "Просперитет"); }
protected override async Task OnAfterRenderAsync(bool firstRender) { if (_loaded) { return; } _loaded = true; _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). StartsWith("admin/machine_families/create", StringComparison.InvariantCulture); if (Id <= 0 && !_creating) { return; } _companies = await CompaniesService.GetAsync(); _model = _creating ? new MachineFamilyViewModel() : await Service.GetAsync(Id); _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). StartsWith("admin/machine_families/edit/", StringComparison.InvariantCulture); StateHasChanged(); }
protected override async Task OnAfterRenderAsync(bool firstRender) { if (_loaded) { return; } _loaded = true; _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). StartsWith("admin/software_versions/create", StringComparison.InvariantCulture); if (Id <= 0 && !_creating) { return; } _softwareVersions = await Service.GetAsync(); _softwareFamilies = await SoftwareFamiliesService.GetAsync(); _licenses = await LicensesService.GetAsync(); _companies = await CompaniesService.GetAsync(); _roles = await DocumentRolesService.GetEnabledAsync(); _model = _creating ? new SoftwareVersionViewModel() : await Service.GetAsync(Id); _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); _addingCompanyRoleId = _roles.First().Id; _softwareVersionCompanies = await CompaniesBySoftwareVersionService.GetBySoftwareVersion(Id); _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). StartsWith("admin/software_versions/edit/", StringComparison.InvariantCulture); if (_editing) { SetCheckboxes(); } StateHasChanged(); }
protected override async Task OnAfterRenderAsync(bool firstRender) { if (_loaded) { return; } _loaded = true; _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). StartsWith("admin/processors/create", StringComparison.InvariantCulture); if (Id <= 0 && !_creating) { return; } _companies = await CompaniesService.GetAsync(); _instructionSets = await InstructionSetsService.GetAsync(); _model = _creating ? new ProcessorViewModel() : await Service.GetAsync(Id); _instructionSetExtensions = await InstructionSetExtensionsService.GetAsync(); _processorExtensions = await InstructionSetExtensionsByProcessorService.GetByProcessor(Id); _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). StartsWith("admin/processors/edit/", StringComparison.InvariantCulture); if (_editing) { SetCheckboxes(); } StateHasChanged(); }