public void Add_Seller_To_Data_Store()
        {
            //Arrange
            using (var bc = new UnitOfWork())
            {
                var seller = new Seller
                {
                    FirstName = "Michał",
                    LastName = "Rakel",
                    BankName = "mBank",
                    BankAccountNumber = "32 3245 5456 5435 3242 5456 1296",
                    NIP = "3234326576",
                    Address = new Address
                    {
                        City = "Kraków",
                        StreetAddress = "ul. Kredki 5/8a",
                        ZipCode = "31-063"
                    }
                };

                //Act
                bc.People.Add(seller);
                bc.Complete();
            }

            using (var bc = new UnitOfWork())
            {
                //Verify
                bool exists = bc.People.GetBasicSellersData().Any();

                Assert.IsTrue(exists);
            }
        }
        public void Add_Seller_To_Collection_When_Received_From_SellerVM()
        {
            //Arrange
            _sellerListViewModel = new SellerListViewModel(_contextMock.Object);

            const int sellerId = 2;

            var sellerToAdd = new Seller
            {
                ID = sellerId,
                FirstName = "Michał",
                LastName = "Rakel",
                BankName = "mBank",
                BankAccountNumber = "32 3245 5456 5435 3242 5456 1296",
                NIP = "3234326576",
                Address = new Address
                {
                    City = "Kraków",
                    StreetAddress = "ul. Kredki 5/8a",
                    ZipCode = "31-063"
                }
            };

            //Act
            Messenger.Default.Send(new MessageService(sellerToAdd, EntityState.Added), MessengerToken.SellerListVm);

            //Verify
            Assert.IsTrue(_sellerListViewModel.SellerList.Any(s => s.PersonId == sellerId));
        }
Esempio n. 3
0
        public SellerViewModel(IUnitOfWork context,IFrameNavigationService navigationService)
            : base(context,navigationService)
        {
            OriginalModel = new Seller();

            HandleNavigationParameter(navigationService.Parameter);

            ConfigureValidationRules();
        }
Esempio n. 4
0
        private void AddSeller(Seller seller)
        {
            try
            {
                Context.People.Add(seller);
                Context.Complete();
            }
            catch
            {
                throw new Exception("Nie udało się utworzyć sprzedawcy");
            }

            Messenger.Default.Send(new MessageService(seller, EntityState.Added), MessengerToken.SellerListVm);
            StatusSetter.SetStatus("Sprzedawca dodany");
            GoBack();
        }
Esempio n. 5
0
 protected override void ReadFromModel(Person person)
 {
     base.ReadFromModel(person);
     OriginalModel = person as Seller;
     if (OriginalModel != null)
     {
         BankName = OriginalModel.BankName;
         BankAccountNumber = OriginalModel.BankAccountNumber;
     }
 }
        public override void TestInitialize()
        {
            base.TestInitialize();
            using (var bc = new UnitOfWork())
            {
                var newSeller = new Seller
                {
                    FirstName = "Michał",
                    LastName = "Rakel",
                    BankName = "mBank",
                    BankAccountNumber = "32 3245 5456 5435 3242 5456 1296",
                    NIP = "3234326576",
                    Address = new Address
                    {
                        City = "Kraków",
                        StreetAddress = "ul. Kredki 5/8a",
                        ZipCode = "31-063"
                    }
                };

                bc.People.Add(newSeller);

                var newBuyer = new Buyer
                {
                    FirstName = "Michał",
                    LastName = "Braik",
                    CompanyName = "Ven",
                    NIP = "562504040",
                    Address = new Address
                    {
                        City = "Warszawa",
                        StreetAddress = "Tor wyścigowy 54",
                        ZipCode = "42-232"
                    }
                };

                newSeller.Buyers.Add(newBuyer);
                bc.Complete();
            }
        }
Esempio n. 7
0
 public MessageService(Seller seller, EntityState entityState)
 {
     Seller = seller;
     EntityState = entityState;
 }
        public void BuyersAssignedToSeller_Gets_List_Of_Buyers_For_Seller()
        {
            //Arrange
            int sellerId;
            using (var bc = new UnitOfWork())
            {
                var seller = new Seller
                {
                    FirstName = "Michał",
                    LastName = "Rakel",
                    BankName = "mBank",
                    BankAccountNumber = "32 3245 5456 5435 3242 5456 1296",
                    NIP = "3234326576",
                    Address = new Address
                    {
                        City = "Kraków",
                        StreetAddress = "ul. Kredki 5/8a",
                        ZipCode = "31-063"
                    }
                };

                var buyer1 = new Buyer
                {
                    FirstName = "Paweł",
                    LastName = "Rakel",
                    NIP = "3234326576",
                    Address = new Address
                    {
                        City = "Kraków",
                        StreetAddress = "ul. Kredki 5/8a",
                        ZipCode = "31-063"
                    }
                };

                var buyer2 = new Buyer
                {
                    FirstName = "Piotrek",
                    LastName = "Rakel",
                    NIP = "3234326576",
                    Address = new Address
                    {
                        City = "Kraków",
                        StreetAddress = "ul. Kredki 5/8a",
                        ZipCode = "31-063"
                    }
                };

                bc.People.Add(seller);
                seller.Buyers.Add(buyer1);
                seller.Buyers.Add(buyer2);
                bc.Complete();
                sellerId = seller.ID;
            }

            using (var bc = new UnitOfWork())
            {
                //Act
                var buyerList = bc.People.FindBuyers(b => b.Seller.ID == sellerId);

                //Verify
                Assert.IsTrue(buyerList.Count()==2);

            }
        }
Esempio n. 9
0
 private void HandleNavigationParameter(object parameter)
 {
     if (parameter is Seller)
     {
         SelectedSeller = parameter as Seller;
         GetListOfInvoiceDetailsBySellerId();
     }
 }
Esempio n. 10
0
        public void Returns_True_When_Sellers_Are_Equal()
        {
            var aSeller = new Seller
            {
                ID = 1,
                FirstName = "Michał",
                LastName = "Rakel",
                BankName = "mBank",
                BankAccountNumber = "32 3245 5456 5435 3242 5456 1296 ",
                REGON = "df",
                CompanyName = "sdfds",
                NIP = "3234326576",
                Address = new Address
                {
                    City = "Kraków",
                    StreetAddress = "ul. Kredki 5/8a",
                    ZipCode = "31-063"
                }
            };

            var bSeller = new Seller
            {
                ID = 1,
                FirstName = "Michał",
                LastName = "Rakel",
                BankName = "mBank",
                BankAccountNumber = "32 3245 5456 5435 3242 5456 1296 ",
                REGON = "df",
                CompanyName = "sdfds",
                NIP = "3234326576",
                Address = new Address
                {
                    City = "Kraków",
                    StreetAddress = "ul. Kredki 5/8a",
                    ZipCode = "31-063"
                }
            };

            Assert.IsTrue(aSeller.Equals(bSeller));
        }
Esempio n. 11
0
        public void GetShortenedPeople_Returns_Data()
        {
            //Arrange
            using (var bc = new UnitOfWork())
            {
                var seller = new Seller
                {
                    FirstName = "Michał",
                    LastName = "Rakel",
                    BankName = "mBank",
                    BankAccountNumber = "32 3245 5456 5435 3242 5456 1296",
                    NIP = "3234326576",
                    Address = new Address
                    {
                        City = "Kraków",
                        StreetAddress = "ul. Kredki 5/8a",
                        ZipCode = "31-063"
                    }
                };

                bc.People.Add(seller);
                var seller2 = new Seller
                {
                    FirstName = "Paweł",
                    LastName = "Rakel",
                    BankName = "mBank",
                    BankAccountNumber = "43 3245 5456 5435 3242 5456 1296",
                    NIP = "3265326576",
                    Address = new Address
                    {
                        City = "Warszawa",
                        StreetAddress = "ul. Kredki 5/8a",
                        ZipCode = "31-063"
                    }
                };

                bc.People.Add(seller2);
                bc.Complete();

                //Act
                var list = bc.People.GetBasicSellersData();

                //Verify
                Assert.IsTrue(list.Count() == 2);
            }
        }
Esempio n. 12
0
 private void HandleNavigationParameter(object parameter)
 {
     if (parameter is Seller)
     {
         SelectedSeller = parameter as Seller;
     }
 }
        private Invoice CreateInvoice()
        {
            var buyer = new Buyer
            {
                ID = 2,
                FirstName = "Tomasz",
                LastName = "Pakul",
                CompanyName = "Tymbol",
                NIP = "5455914065",
                Address = new Address
                {
                    City = "Kraków",
                    StreetAddress = "ul. Kolorowe 3",
                    ZipCode = "30-710"
                }
            };

            _selectedSeller = new Seller
            {
                ID = 1,
                FirstName = "Michał",
                LastName = "Rakel",
                BankName = "mBank",
                BankAccountNumber = "32 3245 5456 5435 3242 5456 1296 ",
                NIP = "3234326576",
                Address = new Address
                {
                    City = "Kraków",
                    StreetAddress = "ul. Kredki 5/8a",
                    ZipCode = "31-063"
                }
            };
            var myInvoice = new Invoice
            {
                ID = 1,
                IssueDate = new DateTime(2015, 5, 6),
                Number = "3/2015",
                PaymentMethod = PaymentMethod.Transfer,
                SaleDate = new DateTime(2015, 5, 6),
                PaymentDetails = new List<PaymentDetail>
                         {
                            new PaymentDetail
                            {
                                Description = "Czynsz za lokal ul. Marsa 3 maj",
                                MeasureUnit = "szt.",
                                PricePerUnit = 5300,
                                Quantity = 1
                            },
                            new PaymentDetail
                            {
                                Description = "Czynsz za lokal ul. wris 3 lipiec",
                                MeasureUnit = "szt.",
                                PricePerUnit = 3500,
                                Quantity = 1
                            }

                         },

                Buyer = buyer,
                Seller = _selectedSeller,
            };

            return myInvoice;
        }
Esempio n. 14
0
        public void When_Navigation_Parameter_Is_Int_Invoke_GetSeller()
        {
            //Arrange
            var seller = new Seller
            {
                ID = 1
            };
            _navigationServiceMock.SetupGet(m => m.Parameter).Returns(seller.ID);
            _contextMock.Setup(m => m.People.GetSeller(It.IsAny<int>())).Returns(seller);

            //Act
            _invoiceViewModel = new InvoiceViewModel(_contextMock.Object, _messageBoxMock.Object, _navigationServiceMock.Object);

            //Verify
            _contextMock.Verify(m=>m.People.GetSeller(It.IsAny<int>()),Times.Once);
        }
Esempio n. 15
0
        public void When_Navigation_Parameter_Is_Int_Initialize_With_Mode_Add()
        {
            //Arrange
            var seller = new Seller
            {
                ID = 1
            };
            _navigationServiceMock.SetupGet(m => m.Parameter).Returns(seller.ID);
            _contextMock.Setup(m => m.People.GetSeller(It.IsAny<int>())).Returns(seller);

            //Act
            _invoiceViewModel = new InvoiceViewModel(_contextMock.Object, _messageBoxMock.Object, _navigationServiceMock.Object);

            //Verify
            Assert.IsTrue(_invoiceViewModel.Mode == Mode.Add);
        }
Esempio n. 16
0
        public void When_Initialized_Invoke_GetBuyerListFromSeller()
        {
            //Arrange
            var seller = new Seller
            {
                ID = 1
            };
            _navigationServiceMock.SetupGet(m => m.Parameter).Returns(seller.ID);
            _contextMock.Setup(m => m.People.GetSeller(It.IsAny<int>())).Returns(seller);

            _selectedSeller.Buyers.Clear();

            //Act
            _invoiceViewModel = new InvoiceViewModel(_contextMock.Object, _messageBoxMock.Object, _navigationServiceMock.Object);

            //Verify
            _contextMock.Verify(m => m.People.FindBuyers(It.IsAny<Expression<Func<Buyer, bool>>>()), Times.Once());
        }
Esempio n. 17
0
        public void SetUp()
        {
            _contextMock = new Mock<IUnitOfWork>();
            _navigationServiceMock = new Mock<IFrameNavigationService>();
            _messageBoxMock = new Mock<IMessageBoxService>();

            _buyers = new List<Buyer>();

            _selectedSeller = CreateSeller();

            CreateBuyerList();

            _contextMock.Setup(m => m.Payments.Add(It.IsAny<Payment>())).Callback<Payment>(newInvoice =>
            {
                newInvoice.ID = 1;
            });

            _contextMock.Setup(m => m.Payments.RemoveById(It.IsAny<int>()));
        }
Esempio n. 18
0
        private void EditSeller(Seller seller)
        {
            try
            {
                Context.Complete();
            }
            catch
            {
                throw new Exception("Nie udało się zmodyfikować sprzedawcy");
            }

            Messenger.Default.Send(new MessageService(seller, EntityState.Edited), MessengerToken.SellerListVm);
            StatusSetter.SetStatus("Sprzedawca zmodyfikowany");
            GoBack();
        }
Esempio n. 19
0
        public void When_navigationService_Parameter_Is_Not_Null_Initialize_With_Mode_Edit()
        {
            //Arrange
            var seller = new Seller();
            _navigationServiceMock.Setup(m => m.Parameter).Returns(seller);

            //Act
            _sellerViewModel = new SellerViewModel(_contextMock.Object, _navigationServiceMock.Object);

            //Verify
            Assert.IsTrue(_sellerViewModel.Mode == Mode.Edit);
        }
Esempio n. 20
0
        public void Remove_Seller_From_Data_Store()
        {
            //Arrange
            int id;
            using (var bc = new UnitOfWork())
            {
                var seller = new Seller
                {
                    FirstName = "Michał",
                    LastName = "Rakel",
                    BankName = "mBank",
                    BankAccountNumber = "32 3245 5456 5435 3242 5456 1296",
                    NIP = "3234326576",
                    Address = new Address
                    {
                        City = "Kraków",
                        StreetAddress = "ul. Kredki 5/8a",
                        ZipCode = "31-063"
                    }
                };

                //Act
                bc.People.Add(seller);
                bc.Complete();
                id = seller.ID;
            }

            using (var bc = new UnitOfWork())
            {
                //Verify
                var sellerToDelete = bc.People.GetSeller(id);
                bc.People.Remove(sellerToDelete);
                bc.Complete();
                Assert.IsFalse(bc.People.GetBasicSellersData().Any());
            }
        }
Esempio n. 21
0
 private bool Equals(Seller other)
 {
     return base.Equals(other) &&
         string.Equals(BankName, other.BankName) &&
         string.Equals(BankAccountNumber, other.BankAccountNumber);
 }
 private void CreateSeller()
 {
     _selectedSeller = new Seller
     {
         ID = 1,
         FirstName = "Michał",
         LastName = "Rakel",
         BankName = "mBank",
         BankAccountNumber = "32 3245 5456 5435 3242 5456 1296 ",
         NIP = "3234326576",
         Address = new Address
         {
             City = "Kraków",
             StreetAddress = "ul. Kredki 5/8a",
             ZipCode = "31-063"
         }
     };
 }