private void InitializeObject(bool UseValidLookupValues) { var pdo = new PredefinedDataObjects(); SetProperty(x => x.Id, ARandom.IntBetween(1000000, int.MaxValue)); SetProperty(x => x.Sequence, ARandom.PositiveInt()); SetProperty(x => x.Title, "Test_" + ARandom.Text(200).TrimEnd()); SetProperty(x => x.AuthorId, UseValidLookupValues ? pdo.Author.Id : ARandom.PositiveInt()); SetProperty(x => x.Test, true); }
private void InitializeObject(bool useValidLookupValues) { SetProperty(x => x.LogBits, new ProductLogBits()); SetProperty(x => x.Id, ARandom.IntBetween(1000000, 2000000)); SetProperty(x => x.ProductTypeId, (Enums.ProductType)ARandom.IntBetween(1, 2)); SetProperty(x => x.ActiveInWebshop, ARandom.Boolean()); SetProperty(x => x.Name_NL, "Test_" + ARandom.Text(200).TrimEnd()); SetProperty(x => x.Name_EN, "Test_" + ARandom.Text(200).TrimEnd()); SetProperty(x => x.Subtitle_NL, ARandom.Text(300).TrimEnd()); SetProperty(x => x.ReferenceNumber, ARandom.Text(20).TrimEnd()); SetProperty(x => x.Isbn, ARandom.String(13)); SetProperty(x => x.Ismn, ARandom.String(13)); SetProperty(x => x.Ean, ARandom.String(13)); SetProperty(x => x.Upc, ARandom.String(12)); SetProperty(x => x.GradeLevel, ARandom.String(10)); SetProperty(x => x.Pages, ARandom.IntBetween(1, Int16.MaxValue)); SetProperty(x => x.SalesPrice, ARandom.CurrencyAmountLessThan(100000)); SetProperty(x => x.TaxRateId, (Enums.TaxRate)ARandom.IntBetween(1, 2)); SetProperty(x => x.Description_NL, ARandom.Text(500).TrimEnd()); SetProperty(x => x.Weight, ARandom.CurrencyAmountLessThan(100)); SetProperty(x => x.Length, ARandom.CurrencyAmountLessThan(100)); SetProperty(x => x.Width, ARandom.CurrencyAmountLessThan(100)); SetProperty(x => x.Height, ARandom.CurrencyAmountLessThan(100)); SetProperty(x => x.InternalStock, ARandom.PositiveInt()); SetProperty(x => x.ExternalStock, ARandom.PositiveInt()); SetProperty(x => x.TeacherDiscount, (byte)ARandom.IntBetween(0, 100)); SetProperty(x => x.ResellerDiscount, (byte)ARandom.IntBetween(0, 100)); SetProperty(x => x.Promotion, ARandom.Boolean()); SetProperty(x => x.HighlightOnHome, ARandom.Boolean()); //TODO: set Besteller property to ARandom.Boolean() when BestSeller is properly supported SetProperty(x => x.BestSeller, false); SetProperty(x => x.MinimumOrderQuantity, ARandom.IntBetween(1, 500)); SetProperty(x => x.SearchKeywords, ARandom.Text(200)); SetProperty(x => x.StorePickupOnly, ARandom.Boolean()); SetProperty(x => x.Test, true); SetProperty(x => x.CreatedDttm, ARandom.DateTimeInPast()); SetProperty(x => x.UpdatedDttm, ARandom.DateTimeInPast()); SetProperty(x => x.DeletedDttm, (DateTime?)null); SetProperty(x => x.Songs, GetRandomSonglist(5, useValidLookupValues)); SetProperty(x => x.ProductPictures, GetRandomProductPictures(5)); SetProperty(x => x.ProductCategories, GetRandomProductCategories(5, useValidLookupValues)); var pdo = new PredefinedDataObjects(); SetProperty(x => x.AuthorId, useValidLookupValues ? pdo.Author.Id : ARandom.PositiveInt()); SetProperty(x => x.ArrangerId, useValidLookupValues ? pdo.Author.Id : ARandom.PositiveInt()); SetProperty(x => x.SupplierId, useValidLookupValues ? pdo.Supplier.Id : ARandom.PositiveInt()); SetProperty(x => x.ManufacturerId, useValidLookupValues ? pdo.Manufacturer.Id : ARandom.PositiveInt()); SetProperty(x => x.InstrumentId, useValidLookupValues ? pdo.Instrument.Id : ARandom.PositiveInt()); SetProperty(x => x.LanguageId, ARandom.EnumValue <Enums.Language>()); SetProperty(x => x.BindingId, useValidLookupValues ? pdo.Binding.Id : ARandom.PositiveInt()); SetProperty(x => x.SeriesId, useValidLookupValues ? pdo.ProductSeries.Id : ARandom.PositiveInt()); }
public void GetAuthorById_with_valid_id_returns_author() { int authorId = new PredefinedDataObjects().Author.Id; var expectedAuthor = new Author { Id = authorId, Name = "Mozart W.A." }; string errorMsg; Author actualAuthor = WebMethods.AuthorMethods.GetAuthorById(authorId, out errorMsg); Assert.AreEqual(expectedAuthor.Id, actualAuthor.Id); Assert.AreEqual(expectedAuthor.Name, actualAuthor.Name); }
public void GetProductById_with_valid_id_returns_product() { int productId = new PredefinedDataObjects().Product(Enums.ProductType.NonBook).Id; var expectedProduct = new Product(); expectedProduct.Id = productId; expectedProduct.Name_NL = "Alhambra 1C klassieke gitaar"; string errorMsg; Product actualProduct = WebMethods.ProductMethods.GetProductById(productId, out errorMsg); Assert.AreEqual(expectedProduct.Id, actualProduct.Id); Assert.AreEqual(expectedProduct.Name_NL, actualProduct.Name_NL); }
public void Get_method_returns_valid_xml() { int authorId = new PredefinedDataObjects().Author.Id; string xmlData = WebMethods.GetDataFromWebMethod("author", "getById", "id=" + authorId); string errorMsg; Assert.IsFalse(WebMethods.WebMethodReturnedError(xmlData, out errorMsg), string.Format("Author with id {0} could not be retrieved from the webshop. Unexpected return value: {1}", authorId, errorMsg)); string validationError = Author.ValidateXmlStructure(xmlData); Assert.IsNull(validationError); }
public void Get_method_returns_valid_xml() { int productId = new PredefinedDataObjects().Product(Enums.ProductType.Book).Id; string xmlData = WebMethods.GetDataFromWebMethod("product", "getById", "id=" + productId); string errorMsg; Assert.IsFalse(WebMethods.WebMethodReturnedError(xmlData, out errorMsg), string.Format("Product with id {0} could not be retrieved from the webshop. Unexpected return value: {1}", productId, errorMsg)); string validationError = Product.ValidateXmlStructure(xmlData); Assert.IsNull(validationError); }
public void Get_method_returns_valid_xml() { int categoryId = new PredefinedDataObjects().ProductCategory.Id; string xmlData = WebMethods.GetDataFromWebMethod("productcategory", "getById", "id=" + categoryId); string errorMsg; Assert.IsFalse(WebMethods.WebMethodReturnedError(xmlData, out errorMsg), string.Format("Product Category with Id {0} could not be retrieved from the webshop. Unexpected return value: {1}", categoryId, errorMsg)); string validationError = ProductCategory.ValidateXmlStructure(xmlData); Assert.IsTrue(validationError == null, validationError); }
private void InitializeObject(bool UseValidLookupValues) { string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string imagePath = appPath + @"\Resources\testcategory.jpg"; string imageFileName = Path.GetFileName(imagePath); var pdo = new PredefinedDataObjects(); SetProperty(x => x.Id, ARandom.IntBetween(10000, 20000)); SetProperty(x => x.ParentId, UseValidLookupValues ? pdo.ProductCategory.Id : ARandom.IntBetween(10000, 20000)); SetProperty(x => x.SortOrder, ARandom.IntBetween(1, 100)); SetProperty(x => x.Name, "Test_" + ARandom.Text(50).TrimEnd()); SetProperty(x => x.PictureFilename, imageFileName); SetProperty(x => x.PictureData, Utility.LoadImageFromFile(imagePath)); SetProperty(x => x.ProductCount, ARandom.PositiveInt()); SetProperty(x => x.TargetUrl, ARandom.String(100)); SetProperty(x => x.Path, ARandom.String(100)); SetProperty(x => x.Test, true); SetProperty(x => x.CreatedDttm, ARandom.DateTimeInPast()); SetProperty(x => x.UpdatedDttm, ARandom.DateTimeInPast()); SetProperty(x => x.DeletedDttm, (DateTime?)null); }