コード例 #1
0
ファイル: Form1.cs プロジェクト: kvitlich/Hommework_03
        public Form1()
        {
            InitializeComponent();
            BuyerRepository buyer = new BuyerRepository(Global.ConnectionStringSql, Global.ProviderName);

            buyer.Add(new Buyer());
        }
コード例 #2
0
        public async Task BoundaryTestFor_validUserNameLengthAsync()
        {
            //mocking
            _mockCollection.Setup(op => op.InsertOneAsync(_buyer, null,
                                                          default(CancellationToken))).Returns(Task.CompletedTask);
            _mockContext.Setup(c => c.GetCollection <Buyer>(typeof(Buyer).Name)).Returns(_mockCollection.Object);

            //Craetion of new Db
            _mockOptions.Setup(s => s.Value).Returns(settings);
            var context  = new MongoDBContext(_mockOptions.Object);
            var userRepo = new BuyerRepository(context);

            //Act
            await userRepo.Create(_buyer);

            var result = await userRepo.Get(_buyer.BuyerId);

            var MinLength = 3;
            var MaxLength = 50;

            //Action
            var actualLength = _buyer.FirstName.Length;

            //Assert
            Assert.InRange(result.FirstName.Length, MinLength, MaxLength);
            Assert.InRange(actualLength, MinLength, MaxLength);
        }
コード例 #3
0
        public async Task BoundaryTestfor_ValidUserEmailAsync()
        {
            //mocking
            _mockCollection.Setup(op => op.InsertOneAsync(_buyer, null,
                                                          default(CancellationToken))).Returns(Task.CompletedTask);
            _mockContext.Setup(c => c.GetCollection <Buyer>(typeof(Buyer).Name)).Returns(_mockCollection.Object);

            //Craetion of new Db
            _mockOptions.Setup(s => s.Value).Returns(settings);
            var context  = new MongoDBContext(_mockOptions.Object);
            var userRepo = new BuyerRepository(context);

            //Act
            await userRepo.Create(_buyer);

            var result = await userRepo.Get(_buyer.BuyerId);

            ////Action
            //  var getregisteredUser = await _userServices.GetUser(user.UserName);
            bool CheckEmail = Regex.IsMatch(result.Email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);
            bool isEmail    = Regex.IsMatch(_buyer.Email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);

            //Assert
            Assert.True(isEmail);
            Assert.True(CheckEmail);
        }
コード例 #4
0
 public MainViewModel(string buyerName, IWarehouseConnection connection, BuyerRepository repository)
 {
     _buyerName         = buyerName;
     _connection        = connection;
     _repository        = repository;
     StartBuyingCommand = new Command(Join);
     Buyers             = new ObservableCollection <BuyerViewModel>();
 }
コード例 #5
0
 public ServerImpl(EmployeeRepository uRepo, ShowRepository sRepo, ArtistRepository aRepo, BuyerRepository bRepo, TicketRepository tRepo)
 {
     userRepository   = uRepo;
     showRepository   = sRepo;
     artistRepository = aRepo;
     buyerRepository  = bRepo;
     ticketRepository = tRepo;
     loggedClients    = new Dictionary <String, IAppObserver>();
 }
コード例 #6
0
ファイル: BuyerViewModel.cs プロジェクト: vkhorikov/AutoBuyer
        public BuyerViewModel(string itemId, int maximumPrice, int numberToBuy,
                              string buyerName, IStockItemConnection connection, BuyerRepository repository)
        {
            ItemId      = itemId;
            _buyer      = new Buyer(buyerName, maximumPrice, numberToBuy);
            _connection = connection;
            _repository = repository;

            _connection.MessageReceived += StockMessageRecieved;
            _repository.Save(ItemId, _buyer);
        }
コード例 #7
0
ファイル: DatabaseSetup.cs プロジェクト: CopperBeardy/SEPUNI
 public void SetupRepositories()
 {
     addressRepository     = new AddressRepository(context);
     appointmentRepository = new AppointmentRepository(context);
     buyerRepository       = new BuyerRepository(context);
     eventRepository       = new EventRepository(context);
     listingRepository     = new ListingRepository(context);
     photoRepository       = new PhotoRepository(context);
     saleRepository        = new SaleRepository(context);
     serviceRepository     = new ServiceRepository(context);
     ticketRepository      = new TicketRepository(context);
 }
コード例 #8
0
        public static void Main(string[] args)
        {
            Console.WriteLine("hi");

            ArtistRepository   artistRepository   = new ArtistRepository();
            EmployeeRepository employeeRepository = new EmployeeRepository();
            BuyerRepository    buyerRepository    = new BuyerRepository();
            ShowRepository     showRepository     = new ShowRepository();
            TicketRepository   ticketRepository   = new TicketRepository();
            IServices          serviceImpl        = new ServerImpl(employeeRepository, showRepository, artistRepository, buyerRepository, ticketRepository);
            AbstractServer     server             = new SerialServer("127.0.0.1", 55555, serviceImpl);

            server.Start();
            Console.WriteLine("Server started ...");
            //Console.WriteLine("Press <enter> to exit...");
            Console.ReadLine();
        }
コード例 #9
0
        public async Task BoundaryTestfor_ValidId()
        {
            //mocking
            _mockCollection.Setup(op => op.InsertOneAsync(_buyer, null,
                                                          default(CancellationToken))).Returns(Task.CompletedTask);
            _mockContext.Setup(c => c.GetCollection <Buyer>(typeof(Buyer).Name)).Returns(_mockCollection.Object);

            //Craetion of new Db
            _mockOptions.Setup(s => s.Value).Returns(settings);
            var context  = new MongoDBContext(_mockOptions.Object);
            var userRepo = new BuyerRepository(context);

            //Act
            await userRepo.Create(_buyer);

            var result = await userRepo.Get(_buyer.BuyerId);

            Assert.InRange(_buyer.BuyerId.Length, 20, 30);
        }
コード例 #10
0
        public async Task GetAllUsers()
        {
            //Arrange
            //Mock MoveNextAsync
            Mock <IAsyncCursor <Buyer> > _userCursor = new Mock <IAsyncCursor <Buyer> >();

            _userCursor.Setup(_ => _.Current).Returns(_list);
            _userCursor
            .SetupSequence(_ => _.MoveNext(It.IsAny <CancellationToken>()))
            .Returns(true)
            .Returns(false);

            //Mock FindSync
            _mockCollection.Setup(op => op.FindSync(It.IsAny <FilterDefinition <Buyer> >(),
                                                    It.IsAny <FindOptions <Buyer, Buyer> >(),
                                                    It.IsAny <CancellationToken>())).Returns(_userCursor.Object);

            //Mock GetCollection
            _mockContext.Setup(c => c.GetCollection <Buyer>(typeof(Buyer).Name)).Returns(_mockCollection.Object);

            //Jayanth Creating one more instance of DB

            _mockOptions.Setup(s => s.Value).Returns(settings);

            // Creating one more instance of DB
            // Passing _mockOptions instaed of _mockContext
            var context = new MongoDBContext(_mockOptions.Object);

            var userRepo = new BuyerRepository(context);

            //Act
            var result = await userRepo.GetAll();

            //Assert
            //loop only first item and assert
            foreach (Buyer user in result)
            {
                Assert.NotNull(user);
                Assert.Equal(user.FirstName, _buyer.FirstName);
                Assert.Equal(user.Email, _buyer.Email);
                break;
            }
        }
コード例 #11
0
        static void Main(string[] args)
        {
            using (var context = new ApplicationContext())
            {
                var buyerRepository = new BuyerRepository(context);


                context.Database.Migrate();
                var paymentMethod = new PaymentMethod()
                {
                    CardId = "testCard"
                };

                var buyer = new Buyer(paymentMethod);

                var catalogueBrand = new CatalogBrand("Brand");
                var catalogType    = new CatalogType();

                var catalogueItem = new CatalogItem("Beautiful Item", 100, catalogueBrand, catalogType);


                var basket = new Basket(buyer);


                var address = new Address("street", "city", "state", "country", "zipcode");

                var order = new Order(buyer, address, basket);

                buyerRepository.SaveBuyer(buyer);
                context.Basket.Add(basket);
                context.CatalogItem.Add(catalogueItem);
                basket.AddItem(catalogueItem, 1);
                context.Order.Add(order);
                context.CatalogBrand.Add(catalogueBrand);
                context.CatalogType.Add(catalogType);
                context.SaveChanges();


                var a = context.Basket.Where(x => x.Buyer.PaymentMethods.Any(y => y.CardId == "testCard"));
                var b = context.Buyer.Where(x => x.Basket.Items.Any(y => y.Quantity == 1));
            }
        }
コード例 #12
0
        public async void TestFor_CreateNewUser()
        {
            //mocking
            _mockCollection.Setup(op => op.InsertOneAsync(_buyer, null,
                                                          default(CancellationToken))).Returns(Task.CompletedTask);
            _mockContext.Setup(c => c.GetCollection <Buyer>(typeof(Buyer).Name)).Returns(_mockCollection.Object);

            //Craetion of new Db
            _mockOptions.Setup(s => s.Value).Returns(settings);
            var context  = new MongoDBContext(_mockOptions.Object);
            var userRepo = new BuyerRepository(context);

            //Act
            await userRepo.Create(_buyer);

            var result = await userRepo.Get(_buyer.BuyerId);

            //Assert
            Assert.Equal(_buyer.FirstName, result.FirstName);
        }
コード例 #13
0
        private void ReadFromXML_Click(object sender, RoutedEventArgs e)
        {
            List <Buyer> newBuyersList = new List <Buyer>();

            try
            {
                XDocument doc  = XDocument.Load(@"e:\Обучение\переподготовка\ч.3\курсовая\Project WPF\RealEstataeAgency\RealEstateAgency\bin\Debug\Data.xml");
                var       root = doc.Root;
                foreach (var element in root.Elements())
                {
                    var buyer = new Buyer();
                    buyer.BuyerID      = int.Parse(element.Element("id").Value);
                    buyer.BuyerName    = element.Element("name").Value;
                    buyer.BuyerAdress  = element.Element("adress").Value;
                    buyer.BuyerUNP     = int.Parse(element.Element("unp").Value);
                    buyer.BuyerPhone   = element.Element("phone").Value;
                    buyer.BuyerRequest = element.Element("request").Value;

                    newBuyersList.Add(buyer);
                }

                IBuyerRepository buyerXMLRepository = new BuyerRepository();
                foreach (var buyerRepo in buyerXMLRepository.GetAll())
                {
                    buyerXMLRepository.DeleteBuyer(buyerRepo);
                }

                foreach (var buyerXML in newBuyersList)
                {
                    buyerXMLRepository.AddBuyer(buyerXML);
                }

                UpdateSelectedBuyer();
                MessageBox.Show("Данные  импортированы");
            }
            catch (Exception ex) { MessageBox.Show("Невозможно импортировать данные."); }
        }
コード例 #14
0
        public async Task TestFor_GetBuyerById()
        {
            //Arrange

            //mocking
            _mockCollection.Setup(op => op.FindSync(It.IsAny <FilterDefinition <Buyer> >(),
                                                    It.IsAny <FindOptions <Buyer, Buyer> >(),
                                                    It.IsAny <CancellationToken>()));

            _mockContext.Setup(c => c.GetCollection <Buyer>(typeof(Buyer).Name));

            //Craetion of new Db
            _mockOptions.Setup(s => s.Value).Returns(settings);
            var context  = new MongoDBContext(_mockOptions.Object);
            var userRepo = new BuyerRepository(context);

            //Act
            await userRepo.Create(_buyer);

            var result = await userRepo.Get(_buyer.BuyerId);

            //Assert
            Assert.NotNull(result);
        }
コード例 #15
0
        public async Task BoundaryTestfor_ValidUserNameAsync()
        {
            //mocking
            _mockCollection.Setup(op => op.InsertOneAsync(_buyer, null,
                                                          default(CancellationToken))).Returns(Task.CompletedTask);
            _mockContext.Setup(c => c.GetCollection <Buyer>(typeof(Buyer).Name)).Returns(_mockCollection.Object);

            //Craetion of new Db
            _mockOptions.Setup(s => s.Value).Returns(settings);
            var context  = new MongoDBContext(_mockOptions.Object);
            var userRepo = new BuyerRepository(context);

            //Act
            await userRepo.Create(_buyer);

            var result = await userRepo.Get(_buyer.BuyerId);

            bool getisUserName = Regex.IsMatch(result.FirstName, @"^[a-zA-Z0-9]{4,10}$", RegexOptions.IgnoreCase);
            bool isUserName    = Regex.IsMatch(_buyer.FirstName, @"^[a-zA-Z0-9]{4,10}$", RegexOptions.IgnoreCase);

            //Assert
            Assert.True(isUserName);
            Assert.True(getisUserName);
        }
コード例 #16
0
 public BuyerService()
 {
     _buyerRepository = new BuyerRepository();
 }
コード例 #17
0
 public BuyerService(BuyerRepository buyerRepository)
 {
     this.buyerRepository = buyerRepository;
 }
コード例 #18
0
 public void SetUp()
 {
     rep  = new BuyerRepository(new EMartDBContext());
     trep = new TranscationRepository(new EMartDBContext());
 }
コード例 #19
0
 public void SetUp()
 {
     _repo = new BuyerRepository(new EMartDBContext());
 }
 public void setup()
 {
     _repo = new BuyerRepository(new EmartDBContext());
 }
コード例 #21
0
 public static BuyerRepository GetBuyerRepository(IUnitOfWork unitOfWork)
 {
     var repository = new BuyerRepository();
     repository.UnitOfWork = unitOfWork;
     return repository;
 }
コード例 #22
0
 public void Setup()
 {
     _repo = new BuyerRepository(new EMARTDBContext());
 }
コード例 #23
0
 public BuyerController(IConfiguration configuration)
 {
     repo = new BuyerRepository(configuration);
 }
コード例 #24
0
        public static List <string[]> Main_(string member)
        {
            List <string[]> result = new List <string[]>();

            Entity[] temp;
            switch (member)
            {
            case "Buyer":
                BuyerRepository buyer = new BuyerRepository(Global.ConnectionStringSql, Global.ProviderName);
                temp = buyer.GetAll().ToArray <Entity>();
                Buyer[] buyers = new Buyer[temp.Length];
                for (int i = 0; i < temp.Length; i++)
                {
                    buyers[i] = (Buyer)temp[i];
                }

                for (int i = 0; i < buyers.Length; i++)
                {
                    result.Add(new string[5]);
                    result[i][0] = buyers[i].Id.ToString();
                    result[i][1] = buyers[i].CreationDate.ToString();
                    result[i][2] = buyers[i].DeletedDate.ToString();
                    result[i][3] = buyers[i].Name.ToString();
                    result[i][4] = buyers[i].Surname.ToString();
                }
                break;

            case "Deal":
                DealRepository deal = new DealRepository(Global.ConnectionStringSql, Global.ProviderName);
                temp = deal.GetAll().ToArray <Entity>();
                Deal[] deals = new Deal[temp.Length];
                for (int i = 0; i < temp.Length; i++)
                {
                    deals[i] = (Deal)temp[i];
                }
                for (int i = 0; i < deals.Length; i++)
                {
                    result.Add(new string[7]);
                    result[i][0] = deals[i].Id.ToString();
                    result[i][1] = deals[i].CreationDate.ToString();
                    //result[i][2] = deals[i].DeletedDate.ToString();
                    result[i][3] = deals[i].IdBuyer.ToString();
                    result[i][4] = deals[i].IdSeller.ToString();
                    result[i][5] = deals[i].Summ.ToString();
                    result[i][6] = deals[i].Date.ToString();
                }
                break;

            case "Saller":
                SallerRepository saller = new SallerRepository(Global.ConnectionStringSql, Global.ProviderName);
                temp = saller.GetAll().ToArray <Entity>();
                Saller[] sallers = new Saller[temp.Length];
                for (int i = 0; i < temp.Length; i++)
                {
                    sallers[i] = (Saller)temp[i];
                }
                for (int i = 0; i < sallers.Length; i++)
                {
                    result.Add(new string[5]);
                    result[i][0] = sallers[i].Id.ToString();
                    result[i][1] = sallers[i].CreationDate.ToString();
                    //result[i][2] = sallers[i].DeletedDate.ToString();
                    result[i][3] = sallers[i].Name.ToString();
                    result[i][4] = sallers[i].Surname.ToString();
                }
                break;
            }

            return(result);
        }