Example #1
0
        private void FillRepo()
        {
            var memberService = new SimpleMemberService(this.MainRepository);
            var service = new AuctionService(this.MainRepository, memberService);

            if (service.GetAll().Any())
                return;

            var me = memberService.GetCurrentMember();

            service.Save(new Auction
            {
                Title = "My asdf Auction",
                StartDateTimeUtc = DateTime.UtcNow.AddSeconds(10),
                EndDateTimeUtc = DateTime.UtcNow.AddDays(14),
                StartPrice = 123,
                Seller = me,
                IsRunning = true,
                IsClosed = false
            });

            service.Save(new Auction
            {
                Title = "My Second Auction",
                StartDateTimeUtc = DateTime.UtcNow.AddSeconds(30),
                EndDateTimeUtc = DateTime.UtcNow.AddDays(24),
                StartPrice = 22,
                Seller = me,
                IsRunning = false,
                IsClosed = true
            });
        }
Example #2
0
        public App()
        {
            var ensureDLLIsCopied = SqlProviderServices.Instance;
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<MainDbContext, Configuration>());

            // this.MainRepository = new FileSystemMainRepository("appdata.json");
            this.MainRepository = new EFMainRepository();
            this.MainRepository.SaveChanges();

            var memberService = new SimpleMemberService(this.MainRepository);
            var service = new AuctionService(this.MainRepository, memberService);

            // Dummy Data
            if (!service.GetAll().Any())
            {
                var me = memberService.GetCurrentMember();
                service.Save(new Auction
                {
                    Title = "My First Auction",
                    StartDateTimeUtc = DateTime.UtcNow.AddSeconds(10),
                    EndDateTimeUtc = DateTime.UtcNow.AddDays(14),
                    StartPrice = 72,
                    Seller = me
                });
            }

            this.AuctionRunner = new AuctionRunner(this.MainRepository);
            this.AuctionRunner.Start();
        }
Example #3
0
        public void AddAuction(object sender, RoutedEventArgs e)
        {
            var repo = ((App) Application.Current).MainRepository;
            var memberService = new SimpleMemberService(repo);
            var service = new AuctionService(repo, memberService);

            var title = this.Title.Text;
            var description = this.Description.Text;
            var startdate = DateTime.Parse(this.Start.Text);
            var enddate = DateTime.Parse(this.End.Text);
            var price = double.Parse(this.StartPrice.Text);
            var member = memberService.GetCurrentMember();
            var image = this.Image.Text;
            var imageArr = File.ReadAllBytes(image);

            var auction = new Auction
            {
                Title = title,
                StartDateTimeUtc = startdate,
                EndDateTimeUtc = enddate,
                StartPrice = price,
                Seller = member,
                Image = imageArr,
                Description = description
            };

            service.Save(auction);
            this.Auctions.Add(auction);
            this.Cancel(sender, e);
        }
        public void GettingCurrentMemberTwice_IsSame()
        {
            var repo = new InMemoryMainRepository();
            var service = new SimpleMemberService(repo);

            var currentMember1 = service.GetCurrentMember();
            var currentMember2 = service.GetCurrentMember();

            Assert.AreEqual(currentMember1, currentMember2);
        }
Example #5
0
        public SellView()
        {
            this.InitializeComponent();
            var app = Application.Current as App;

            var memberService = new SimpleMemberService(app.MainRepository);
            var auctionService = new AuctionService(app.MainRepository, memberService);

            this.DataContext = new SellViewModel(memberService, auctionService);
        }
Example #6
0
        public void WhenAddingAnAuction_WithUnknownMember_RaisesException()
        {
            var auction = CreateGeneratedAuction();

            var repo = new InMemoryMainRepository();

            var service = new AuctionService(repo, new SimpleMemberService(repo));
            var memberService = new SimpleMemberService(repo);

            service.Save(auction);
        }
        public void WhenMemberIsNotInRepo_GetCurrentUser_AlwaysGetAMember()
        {
            var repo = new InMemoryMainRepository();
            var service = new SimpleMemberService(repo);

            var currentMember = service.GetCurrentMember();

            Assert.NotNull(currentMember);
            Assert.IsNotNullOrEmpty(currentMember.DisplayName);
            Assert.IsNotNullOrEmpty(currentMember.EMail);
        }
Example #8
0
        public void PlacingABid_AuctionHasNotYetStarted_RaisesExecption()
        {
            var repo = new InMemoryMainRepository();
            var simpleMemberService = new SimpleMemberService(repo);
            var auction = CreateGeneratedAuction();
            auction.Seller = simpleMemberService.GetCurrentMember();

            var service = new AuctionService(repo, simpleMemberService);

            auction.StartDateTimeUtc = DateTime.UtcNow.AddDays(1);
            service.Save(auction);

            service.PlaceBid(auction, 100);
        }
Example #9
0
        public void GivenAProperService_SavesAValidAuction_ShouldReturnSameFromAuctionList()
        {
            var repo = new InMemoryMainRepository();
            var userService = new SimpleMemberService(repo);
            var service = new AuctionService(repo, userService);

            var auction = CreateGeneratedAuction();

            auction.Seller = userService.Add("Seller", "*****@*****.**");

            service.Save(auction);

            var auctionFromService = service.GetAll().First();
            Assert.AreEqual(auctionFromService, auction);
        }