public async Task GetCompany_returns_the_requested_comapny() { var id = new Guid("daccfa6a-6765-4295-82f1-49480ab2c2c1"); var actual = await repository.GetCompanyAsync(id); var expected = new CompanyDetailsDTO { PlacementDescriptionIds = new [] { 1, 2 }, Id = id, Name = "Spotify" }; Assert.Equal(expected.Id, actual.Id); Assert.Equal(expected.PlacementDescriptionIds.First(), actual.PlacementDescriptionIds.First()); }
public async Task Get_given_id_returns_200_and_company() { var company = new CompanyDetailsDTO { Id = Guid.NewGuid(), Name = "Test" }; repository.Setup(r => r.GetCompanyAsync(company.Id)).ReturnsAsync(company); var controller = new CompanyRepositoryController(repository.Object); var actual = await controller.Get(company.Id, true); var actionResult = Assert.IsType <ActionResult <CompanyDetailsDTO> >(actual); var okResult = Assert.IsType <OkObjectResult>(actionResult.Result); var actualCompany = Assert.IsType <CompanyDetailsDTO>(okResult.Value); Assert.Equal(200, okResult.StatusCode); Assert.Equal(company, actualCompany); }
public CompanyDetailsDTO GetCompanyProfile(int companyId) { CompanyDetailsDTO retVal = new CompanyDetailsDTO() { Id = companyId }; try { DataSet ds = new UserDB(Utility.ConfigurationHelper.GPD_Connection).GetFirmProfile(companyId); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { retVal = new CompanyDetailsDTO() { Id = companyId, Name = DBNull.Value.Equals(ds.Tables[0].Rows[0]["name"]) ? string.Empty : ds.Tables[0].Rows[0]["name"].ToString(), WebSite = DBNull.Value.Equals(ds.Tables[0].Rows[0]["url"]) ? string.Empty : ds.Tables[0].Rows[0]["url"].ToString(), Address = DBNull.Value.Equals(ds.Tables[0].Rows[0]["address_line_1"]) ? string.Empty : ds.Tables[0].Rows[0]["address_line_1"].ToString(), City = DBNull.Value.Equals(ds.Tables[0].Rows[0]["city"]) ? string.Empty : ds.Tables[0].Rows[0]["city"].ToString(), State = DBNull.Value.Equals(ds.Tables[0].Rows[0]["state_province"]) ? string.Empty : ds.Tables[0].Rows[0]["state_province"].ToString(), Country = DBNull.Value.Equals(ds.Tables[0].Rows[0]["country"]) ? string.Empty : ds.Tables[0].Rows[0]["country"].ToString(), PostalCode = DBNull.Value.Equals(ds.Tables[0].Rows[0]["zip_postal_code"]) ? string.Empty : ds.Tables[0].Rows[0]["zip_postal_code"].ToString(), DefaultIndustry = DBNull.Value.Equals(ds.Tables[0].Rows[0]["DefaultIndustry"]) ? string.Empty : ds.Tables[0].Rows[0]["DefaultIndustry"].ToString(), }; } } catch (Exception ex) { log.Error(ex); retVal = new CompanyDetailsDTO() { Id = companyId }; } return(retVal); }