private void AddTestData(AuctioneerDbContext context)
		{
			context.Categories.Add(new TestCategory
			{
				Id = 1, Name = "Computers", Left = 1, Right = 22,
				SubCategories = new TestCategory[]
				{
					new TestCategory { Id = 2, Name = "Desktop computers", Left = 2, Right = 3 },
					new TestCategory { Id = 3, Name = "Mobile computers",  Left = 4, Right = 5 },
					new TestCategory
					{
						Id = 4, Name = "Components", Left = 6, Right = 21,
						SubCategories = new TestCategory[]
						{
							new TestCategory { Id = 5,  Name = "Hard drives",    Left = 7, Right = 8 },
							new TestCategory { Id = 6,  Name = "Graphics cards", Left = 9, Right = 10 },
							new TestCategory { Id = 7,  Name = "Motherboards",   Left = 11, Right = 12 },
							new TestCategory { Id = 8,  Name = "Processors",     Left = 13, Right = 14 },
							new TestCategory { Id = 9,  Name = "RAM memory",     Left = 15, Right = 16 },
							new TestCategory { Id = 15, Name = "Power supplies", Left = 17, Right = 18 },
							new TestCategory { Id = 16, Name = "Cases",          Left = 19, Right = 20 },
						}
					}
				}
			});

			context.Categories.Add(new TestCategory
			{
				Id = 12, Name = "Software", Left = 23, Right = 32,
				SubCategories = new TestCategory[]
				{
					new TestCategory { Id = 13, Name = "Operating systems", Left = 24, Right = 25 },
					new TestCategory { Id = 14, Name = "Office",            Left = 26, Right = 27 },
					new TestCategory { Id = 10, Name = "Security",          Left = 28, Right = 29 },
					new TestCategory { Id = 11, Name = "Games",             Left = 30, Right = 31 },
				}
			});

			context.SaveChanges();

			context.Users.Add(new TestUser { Id = "1" });

			AddAuctionsToCategory(context, 1,  5);
			AddAuctionsToCategory(context, 2,  3, AuctionStatus.Expired);
			AddAuctionsToCategory(context, 3,  2);
			AddAuctionsToCategory(context, 7,  3);
			AddAuctionsToCategory(context, 8,  7);
			AddAuctionsToCategory(context, 12, 3);
			AddAuctionsToCategory(context, 14, 2, AuctionStatus.Sold);
			AddAuctionsToCategory(context, 11, 10);

			context.SaveChanges();
		}
		public static void Add(AuctioneerDbContext context)
		{
			context.Set<BackgroundTasks.BackgroundTasksData>().Add(new BackgroundTasks.BackgroundTasksData
			{
				AuctionExpiryCheckLastRun = DateTime.Now
			});

			context.SaveChanges();
		}
Exemple #3
0
		public static void Add(AuctioneerDbContext context)
		{
			var currencies = new Currency[]
			{
				new Currency("$",  CurrencySymbolPosition.BeforeAmount),
				new Currency("€",  CurrencySymbolPosition.AfterAmountWithSpace),
				new Currency("zł", CurrencySymbolPosition.AfterAmountWithSpace),
				new Currency("£",  CurrencySymbolPosition.BeforeAmount),
			};

			context.Currencies.AddRange(currencies);
			context.SaveChanges();
		}
		public void SetUp()
		{
			mDbContext = new TestAuctioneerDbContext(Effort.DbConnectionFactory.CreateTransient());

			mDbContext.Categories.Add(new TestCategory { Id = 1 });
			mDbContext.Users.Add(new TestUser { Id = "1" });
			mDbContext.Users.Add(new TestUser { Id = "2" });
			mDbContext.Users.Add(new TestUser { Id = "3" });
			mDbContext.SaveChanges();

			mUserNotifierMock = A.Fake<IUserNotifier>();
			var userService   = new UserService(mDbContext, mUserNotifierMock);
			mTestedService    = new AuctionService(mDbContext, mUserNotifierMock, userService, "Ignored", "Ignored");
		}
        private void AddTestData(AuctioneerDbContext context)
        {
            context.Categories.Add(new TestCategory { Id = 1 });
            context.Users.Add(new TestUser { Id = "1" });
            context.SaveChanges();

            mExpiredAuction = new TestAuction
            {
                EndDate = DateTime.Now.Subtract(TimeSpan.FromDays(2))
            };

            mAuctionSoldByBidding = new TestAuction
            {
                EndDate = DateTime.Now.Subtract(TimeSpan.FromDays(3)),
                Offers  = new BuyOffer[]
                {
                    new TestBuyOffer { Amount = 10 }
                }
            };

            mAuctionSoldByBuyout = new TestAuction
            {
                BuyoutPrice = new Money(100, new Currency("$", CurrencySymbolPosition.BeforeAmount)),
                EndDate     = DateTime.Now.AddDays(3),
                Offers      = new BuyOffer[]
                {
                    new TestBuyOffer { Amount = 50 },
                    new TestBuyOffer { Amount = 100 }
                }
            };

            mActiveActionWithoutOffers = new TestAuction
            {
                EndDate = DateTime.Now.AddDays(3)
            };

            mActiveActionWithOffers = new TestAuction
            {
                EndDate = DateTime.Now.AddDays(3),
                Offers  = new BuyOffer[]
                {
                    new TestBuyOffer { Amount = 50 },
                    new TestBuyOffer { Amount = 30 }
                }
            };

            context.Auctions.Add(mExpiredAuction);
            context.Auctions.Add(mAuctionSoldByBidding);
            context.Auctions.Add(mAuctionSoldByBuyout);
            context.Auctions.Add(mActiveActionWithOffers);
            context.Auctions.Add(mActiveActionWithoutOffers);
            context.SaveChanges();
        }
        private void AddTestData(AuctioneerDbContext context)
        {
            context.Categories.Add(new TestCategory { Id = 1 });
            context.Users.Add(new TestUser { Id = "1" });
            context.SaveChanges();

            context.Auctions.Add(new TestAuction
            {
                Id           = 1,
                BuyoutPrice  = new Money(10, new TestCurrency()),
                MinimumPrice = new Money( 5, new TestCurrency()),
            });

            context.Auctions.Add(new TestAuction
            {
                Id           = 2,
                MinimumPrice = new Money(1, new TestCurrency()),
                Offers = new Collection<BuyOffer>
                {
                    new TestBuyOffer { Amount = 5 },
                    new TestBuyOffer { Amount = 8 },
                }
            });

            context.Auctions.Add(new TestAuction
            {
                Id          = 3,
                BuyoutPrice = new Money(6, new TestCurrency()),
            });

            context.Auctions.Add(new TestAuction
            {
                Id           = 4,
                BuyoutPrice  = new Money(50, new TestCurrency()),
                MinimumPrice = new Money(2, new TestCurrency()),
                Offers       = new Collection<BuyOffer>
                {
                    new TestBuyOffer { Amount = 3 },
                    new TestBuyOffer { Amount = 4 },
                }
            });

            context.SaveChanges();
        }
		private void AddTestData(AuctioneerDbContext context)
		{
			context.Categories.AddRange(new TestCategory[]
			{
				new TestCategory
				{
					Id = 1, Left = 1, Right = 10,
					SubCategories = new TestCategory[]
					{
						new TestCategory { Id = 2, Left = 2, Right = 3 },		
						new TestCategory
						{
							Id = 3, Left = 4, Right = 9,						
							SubCategories = new TestCategory[]
							{
								new TestCategory { Id = 4, Left = 5, Right = 6 },		
								new TestCategory { Id = 5, Left = 7, Right = 8 },					
							}	
						},				

					}
				},
				new TestCategory { Id = 6, Left = 11, Right = 12 },
			});

			context.Users.Add(new TestUser { Id = "1" });
			context.Users.Add(new TestUser { Id = "2" });
			context.Users.Add(new TestUser { Id = "3" });
			context.Roles.Add(new IdentityRole { Name = "Admin" });

			context.SaveChanges();

			context.Users.Find("3").Roles.Add(new IdentityUserRole { RoleId = context.Roles.Single().Id, UserId = "3" });

			// TODO the tests are hard to update due to dependencies between test data, how to solve this?
			// The best would be independent data tailored just for single test, but there is a lot of data to setup
			// which will make the class with tests very long.

			context.Auctions.Add(new TestAuction { Id = 1,  Title = "1",  CategoryId = 2, CreationDate = new DateTime(2015, 3, 12),
			                                       EndDate = DateTime.Now.Subtract(TimeSpan.FromDays(2)), SellerId = "1" });

			context.Auctions.Add(new TestAuction { Id = 2,  Title = "2",  CategoryId = 6, CreationDate = new DateTime(2013, 5, 25),
			                                       EndDate = DateTime.Now.Add(TimeSpan.FromDays(2)), SellerId = "1" });

			context.Auctions.Add(new TestAuction { Id = 3,  Title = "3",  CategoryId = 6, CreationDate = new DateTime(2013, 6, 11),
			                                       EndDate = DateTime.Now.Add(TimeSpan.FromDays(2)), SellerId = "2" });

			context.Auctions.Add(new TestAuction { Id = 4,  Title = "4",  CategoryId = 2, CreationDate = new DateTime(2014, 9, 16),
			                                       EndDate = DateTime.Now.Add(TimeSpan.FromDays(1)), SellerId = "1",
																BuyoutPrice = new Money(100, new Currency("$", CurrencySymbolPosition.BeforeAmount)),
																Offers = new Collection<BuyOffer> { new TestBuyOffer { UserId = "2", Amount = 100 } } });

			context.Auctions.Add(new TestAuction { Id = 5,  Title = "5",  CategoryId = 2, CreationDate = new DateTime(2013, 9, 5),
			                                       EndDate = DateTime.Now.Add(TimeSpan.FromDays(2)), SellerId = "1" });

			context.Auctions.Add(new TestAuction { Id = 6,  Title = "6",  CategoryId = 2, CreationDate = new DateTime(2012, 1, 16),
			                                       EndDate = DateTime.Now.Subtract(TimeSpan.FromDays(10)), SellerId = "1" });

			context.Auctions.Add(new TestAuction { Id = 7,  Title = "7",  CategoryId = 2, CreationDate = new DateTime(2014, 12, 22),
			                                       EndDate = DateTime.Now.Add(TimeSpan.FromDays(10)), SellerId = "1" });

			context.Auctions.Add(new TestAuction { Id = 8,  Title = "8",  CategoryId = 2, CreationDate = new DateTime(2013, 1, 12),
			                                       EndDate = DateTime.Now.Add(TimeSpan.FromMinutes(1)), SellerId = "1" });

			context.Auctions.Add(new TestAuction { Id = 9,  Title = "9",  CategoryId = 3, CreationDate = new DateTime(2015, 2, 1),
			                                       EndDate = DateTime.Now.Add(TimeSpan.FromDays(1)), SellerId = "2" });

			context.Auctions.Add(new TestAuction { Id = 10, Title = "10", CategoryId = 5, CreationDate = new DateTime(2014, 4, 30),
			                                       EndDate = DateTime.Now.Add(TimeSpan.FromDays(1)), SellerId = "1" });

			context.Auctions.Add(new TestAuction { Id = 11, Title = "11",  CategoryId = 3, CreationDate = new DateTime(2013, 2, 1),
			                                       EndDate = DateTime.Now.Subtract(TimeSpan.FromDays(1)), SellerId = "2" });

			context.Auctions.Add(new TestAuction { Id = 12, Title = "12",  CategoryId = 3, CreationDate = new DateTime(2013, 2, 1),
			                                       EndDate = DateTime.Now.Subtract(TimeSpan.FromDays(1)), SellerId = "1" });
			context.SaveChanges();
		}
Exemple #8
0
        public static void Add(AuctioneerDbContext context)
        {
            var categories = new Category[]
            {
                new Category
                {
                    Name          = "Computers",
                    SubCategories = new Category[]
                    {
                        new Category { Name = "Desktop computers" },
                        new Category
                        {
                            Name          = "Mobile computers",
                            SubCategories = new Category[]
                            {
                                new Category { Name = "Tablets" },
                                new Category { Name = "Netbooks" },
                                new Category { Name = "Notebooks" },
                            }
                        },
                        new Category
                        {
                            Name          = "Components",
                            SubCategories = new Category[]
                            {
                                new Category { Name = "Hard drives" },
                                new Category { Name = "Graphics cards" },
                                new Category { Name = "Motherboards" },
                                new Category { Name = "Processors" },
                                new Category { Name = "RAM memory" },
                                new Category { Name = "Power supplies" },
                                new Category { Name = "Cases" },
                            }
                        }
                    }
                },
                new Category
                {
                    Name          = "Sport",
                    SubCategories = new Category[]
                    {
                        new Category
                        {
                            Name          = "Cycling",
                            SubCategories = new Category[]
                            {
                                new Category { Name = "Bicycles" },
                                new Category { Name = "Accessories" },
                                new Category { Name = "Clothing" }
                            }
                        },
                        new Category
                        {
                            Name          = "Team sports",
                            SubCategories = new Category[]
                            {
                                new Category { Name = "Baseball" },
                                new Category { Name = "Soccer" },
                                new Category { Name = "Hockey" },
                            }
                        },
                        new Category { Name = "Weightlifting" }
                    }
                },
                new Category
                {
                    Name          = "Software",
                    SubCategories = new Category[]
                    {
                        new Category
                        {
                            Name          = "Operating systems",
                            SubCategories = new Category[]
                            {
                                new Category { Name = "Microsoft Windows" },
                                new Category { Name = "Apple OS X" },
                                new Category { Name = "Linux" },
                                new Category { Name = "Other" },
                            }
                        },
                        new Category { Name = "Office" },
                        new Category { Name = "Security" },
                        new Category
                        {
                            Name          = "Games",
                            SubCategories = new Category[]
                            {
                                new Category { Name = "XBox One" },
                                new Category { Name = "Xbox 360" },
                                new Category { Name = "PlayStation 4" },
                                new Category { Name = "PlayStation 3" },
                                new Category { Name = "PC" },
                                new Category { Name = "Other" },
                            }
                        },
                        new Category { Name = "Programming software" },
                        new Category { Name = "Other" },
                    }
                }
            };

            InitializeNestedSetProperties(categories);

            context.Categories.AddRange(categories);
            context.SaveChanges();
        }