public void Get_GetNotExistingBrand_ShouldReturnFalse() { //Arrange BrandCollection brandCollection = new BrandCollection(new BrandTestDAL()); Brand brand0 = new Brand() { Name = "TestNameGet1", Origin = "TestOriginGet1" }; Brand brand1 = new Brand() { Name = "TestNameGet2", Origin = "TestOriginGet2" }; brandCollection.Create(brand0); brandCollection.Create(brand1); Brand expected = new Brand() { Id = 1, Name = "TestNameGet2", Origin = "TestOriginGet2" }; //Act Brand get = brandCollection.Get(5); //Assert Assert.AreNotEqual(get.Id, expected.Id); Assert.AreNotEqual(get.Name, expected.Name); Assert.AreNotEqual(get.Origin, expected.Origin); }
public object GetBrandList() { BrandCollection brands = new BrandCollection(); brands.GetMulti(null); return(brands); }
public void Delete_DeleteSecondCreatedBrand_ShouldReturnTrue() { //Arrange BrandCollection brandCollection = new BrandCollection(new BrandTestDAL()); Brand brand0 = new Brand() { Id = 0, Name = "TestNameGet1", Origin = "TestOriginGet1" }; Brand brand1 = new Brand() { Id = 1, Name = "TestNameGet2", Origin = "TestOriginGet2" }; brandCollection.Create(brand0); brandCollection.Create(brand1); bool expected = true; //Act bool actual = brandCollection.Delete(1); //Assert Assert.AreEqual(actual, expected); }
private bool UpdateBrand(BrandModel brand) { Brand databaseBrand = new BrandCollection().Get(brand.Id); databaseBrand.SetName(brand.Name); databaseBrand.SetOrigin(brand.Origin); return(databaseBrand.Update()); }
private BrandModel GetBrand(int brandId) { Brand databaseBrand = new BrandCollection().Get(brandId); BrandModel brand = new BrandModel() { Id = databaseBrand.Id, Name = databaseBrand.Name, Origin = databaseBrand.Origin }; return(brand); }
public void GetAll_GetAll3CreatedBrands_ShouldReturnTrue() { //Arrange BrandCollection brandCollection = new BrandCollection(new BrandTestDAL()); Brand brand0 = new Brand() { Id = 0, Name = "TestNameGet1", Origin = "TestOriginGet1" }; Brand brand1 = new Brand() { Id = 1, Name = "TestNameGet2", Origin = "TestOriginGet2" }; Brand brand2 = new Brand() { Id = 2, Name = "TestNameGet3", Origin = "TestOriginGet3" }; brandCollection.Create(brand0); brandCollection.Create(brand1); brandCollection.Create(brand2); List <Brand> expectedBrandList = new List <Brand>(); expectedBrandList.Add(brand0); expectedBrandList.Add(brand1); expectedBrandList.Add(brand2); bool actual = true; //Act List <Brand> actualBrandList = brandCollection.GetAll(); //Assert for (int i = 0; i < 2; i++) { if (expectedBrandList[i].Id != actualBrandList[i].Id & expectedBrandList[i].Name != actualBrandList[i].Name & expectedBrandList[i].Origin != actualBrandList[i].Origin) { actual = false; } } Assert.AreEqual(true, actual); }
public void Create_CreateBrandWithEmptyBrandObject_ShouldReturnFalse() { //Arrange bool expected = false; BrandCollection brandCollection = new BrandCollection(new BrandTestDAL()); Brand brand = new Brand(); //Act bool actual = brandCollection.Create(brand); //Assert Assert.AreEqual(actual, expected); }
/// <summary> /// Initialises the Feed Manager /// </summary> /// <param name="accessKey">The access key identifies the client</param> /// <param name="secretKey">The secret key is used for authentication when publishing a feed</param> /// <param name="region">The region defines the endpoints that are used and thus matches the geo region in which the clients PureClarity instance lives</param> public FeedManager(string accessKey, string secretKey, int region) { _accessKey = accessKey ?? throw new System.ArgumentNullException(nameof(accessKey)); _secretKey = secretKey ?? throw new System.ArgumentNullException(nameof(secretKey)); _region = region; _productCollection = new ProductCollection(); _categoryCollection = new CategoryCollection(); _brandCollection = new BrandCollection(); _accountPriceCollection = new AccountPriceCollection(); _userCollection = new UserCollection(); _deletedProductCollection = new DeletedProductCollection(); _deletedAccountPriceCollection = new DeletedAccountPriceCollection(); }
public void Create_CreateBrandWithValidBrandObject_ShouldReturnTrue() { //Arrange bool expected = true; BrandCollection brandCollection = new BrandCollection(new BrandTestDAL()); Brand brand = new Brand() { Name = "TestNameCreate1", Origin = "TestOriginCreate1" }; //Act bool actual = brandCollection.Create(brand); //Assert Assert.AreEqual(actual, expected); }
public void Delete_DeletingNonExistingBrand_ShouldReturnFalse() { //Arrange BrandCollection brandCollection = new BrandCollection(new BrandTestDAL()); Brand brand0 = new Brand() { Id = 0, Name = "TestNameGet1", Origin = "TestOriginGet1" }; brandCollection.Create(brand0); bool expected = false; //Act bool actual = brandCollection.Delete(3); //Assert Assert.AreEqual(actual, expected); }
public object GetBrandList() { BrandCollection brands = new BrandCollection(); brands.GetMulti(null); return brands; }
private void SetupReferenceData() { var countries = new Country { CountryId = "1", Name = "USA", Code = "USA" }; var states = new State { StateId = "2", CountryId = "1", Name = "Florida" }; var ports = new Port { PortId = "1", City = "Florida", Name = "Miami", State = "Florida", StateId = "2", CountryId = "1" }; var brands = new Brand { BrandId = "1", Name = "Carnival" }; var personTypes = new PersonTypeEntity { PersonTypeId = "1001", Name = "Daniel" }; var loyaltyLevelTypes = new LoyaltyLevelType { LoyaltyLevelTypeId = "1001", Name = "abc", BrandId = "1", NoOfCruiseNights = 3, LogoImageAddress = "abc" }; var documentType = new DocumentType { CountryId = "232", Code = "USA", DocumentTypeId = "1", Name = "Passport" }; var brand = new BrandCollection(); var country = new CountryCollection(); country.Add(countries); var state = new StateCollection(); state.Add(states); var documentTypes = new DocumentTypeCollection(); documentTypes.Add(documentType); var port = new PortCollection(); port.Add(ports); var personTypeEntity = new PersonTypeEntityCollection(); personTypeEntity.Add(personTypes); var loyaltyLevelType = new LoyaltyLevelTypeCollection(); loyaltyLevelType.Add(loyaltyLevelTypes); this.referenceData.AssignBrands(brand); this.referenceData.AssignCountries(country); this.referenceData.AssignStates(state); this.referenceData.AssignDocumentTypes(documentTypes); this.referenceData.AssignLoyaltyLevelTypes(loyaltyLevelType); this.referenceData.AssignPersonTypes(personTypeEntity); this.referenceData.AssignPorts(port); }
/// <summary> /// Function to map Brands. /// </summary> /// <param name="dataReader">Instance of SqlDataReader</param> /// <returns>Brand Collection</returns> private static async Task<BrandCollection> MapBrands(SqlDataReader dataReader) { var brandCollection = new BrandCollection(); if (dataReader != null) { while (await dataReader.ReadAsync()) { var brand = new Brand { BrandId = dataReader.Int16Field(BrandId).ToString(), Name = dataReader.StringField(Name), MediaItemAddress = dataReader.StringField(MediaItemAddress) }; byte[] bytes = await brand.MediaItemAddress.ImageAddressToByteArray(); brand.BrandIcon = bytes.ToBitmapSource(); brandCollection.Add(brand); } } return brandCollection; }
/// <summary> /// Maps the brand port ids. /// </summary> /// <param name="brands">The brands.</param> /// <param name="dictionaryPortBrand">The dictionary port brand.</param> private static void MapBrandPortIds(BrandCollection brands, IDictionary<int, Collection<int>> dictionaryPortBrand) { foreach (var brand in brands) { var brandId = Convert.ToInt32(brand.BrandId, CultureInfo.CurrentCulture); if (dictionaryPortBrand != null && dictionaryPortBrand.ContainsKey(brandId)) { var portIdList = dictionaryPortBrand[brandId].ToList(); if (brand.PortIds != null && brand.PortIds.Count > 0) { portIdList.Iterate(a => { if (!brand.PortIds.Any(b => int.Equals(a, b))) { brand.PortIds.Add(a); } }); } else { brand.AssignPortIds(portIdList); } } } }