Exemplo n.º 1
0
        public void ProductDictionarySerializationTXTTest()
        {
            Dictionary <int, Product> products = new Dictionary <int, Product>
            {
                { 0, new Product {
                      Name = "Yamaha 2.0", Price = 3200.99
                  } },
                { 1, new Product {
                      Name = "Yamaha 2", Price = 400.99
                  } },
                { 2, new Product {
                      Name = "Ibanez 2111", Price = 402130.99
                  } },
                { 3, new Product {
                      Name = "Cort 242", Price = 4111100.99
                  } },
                { 4, new Product {
                      Name = "Yamaha -4", Price = 4500.99
                  } },
            };

            TxtPROConverter txtcon = new TxtPROConverter();

            txtcon.writeProductsDictionary(products, "products.txt");
            Dictionary <int, Product> deProducts = txtcon.readProductsDictionary("products.txt");

            for (int i = 0; i < products.Count; i++)
            {
                Assert.AreEqual(products[i].ToString(), deProducts[i].ToString());
            }
        }
Exemplo n.º 2
0
        public void ProductDictionarySerializationCountTXTTest()
        {
            Dictionary <int, Product> products = new Dictionary <int, Product>
            {
                { 1, new Product {
                      Name = "Yamaha 2", Price = 400.99
                  } },
                { 2, new Product {
                      Name = "Ibanez 2111", Price = 402130.99
                  } },
                { 3, new Product {
                      Name = "Cort 242", Price = 4111100.99
                  } },
                { 4, new Product {
                      Name = "Yamaha -4", Price = 4500.99
                  } },
            };

            TxtPROConverter txtcon = new TxtPROConverter();

            txtcon.writeProductsDictionary(products, "products.txt");
            Dictionary <int, Product> deProducts = txtcon.readProductsDictionary("products.txt");

            Assert.AreEqual(products.Count, deProducts.Count);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            DataRepository _DataRepository = new DataRepository();

            _DataRepository.CreateProduct(ProductType.Keyboard, "Keyboard", 100);
            _DataRepository.FillRepository = new FillRepository();
            _DataRepository.FillClients();
            _DataRepository.FillProducts();
            _DataRepository.FillTransactions();
            DataService _DataService = new DataService(_DataRepository);

            _DataRepository.CreateTransaction(2, 2, "17 wrzesnia");
            _DataRepository.CreateTransaction(5, 4, "13 wrzesnia");



            TxtPROConverter pro = new TxtPROConverter();

            //pro.writeClientsList(_DataRepository.GetAllClients(), "tclients.txt");
            pro.writeObject(new Client("Tadeusz", BirthYear: 2010), "myclient.txt");
            pro.writeObject(new Product("Tadeusz 2000", 34.99), "myproduct.txt");
            //Console.WriteLine(pro.readClient("myclient.txt").ToString());
            //Console.WriteLine(pro.readProduct("myproduct.txt").ToString());

            Console.WriteLine("SERIALIZACJA:");
            Serializer serializer = new Serializer(_DataRepository);

            serializer.start();

            Console.ReadKey();
        }
Exemplo n.º 4
0
        public void TransactionSerializationTXTTest()
        {
            Transaction     transaction = new Transaction(3, 3, "5 maja");
            TxtPROConverter txtcon      = new TxtPROConverter();

            txtcon.writeObject(transaction, "transaction.txt");
            Transaction secondClient = txtcon.readTransaction("transaction.txt");

            Assert.AreEqual(transaction.ToString(), secondClient.ToString());
        }
Exemplo n.º 5
0
        public void ProductSerializationTXTTest()
        {
            Product         product = new Product("Ibanez 200", 349.55);
            TxtPROConverter txtcon  = new TxtPROConverter();

            txtcon.writeObject(product, "product.txt");
            Product secondClient = txtcon.readProduct("product.txt");

            Assert.AreEqual(product.ToString(), secondClient.ToString());
        }
Exemplo n.º 6
0
        public void ClientSerializationTXTTest()
        {
            Client          client = new Client("Tadeusz", "Nowak", "Random Street 23", "Lodz", 2005);
            TxtPROConverter txtcon = new TxtPROConverter();

            txtcon.writeObject(client, "client.txt");
            Client secondClient = txtcon.readClient("client.txt");

            Assert.AreEqual(client.ToString(), secondClient.ToString());
        }
Exemplo n.º 7
0
        public void ClientListSerializationCountTXTTest()
        {
            List <Client> clients = new List <Client>
            {
                new Client("Tadeusz", "Nowak", " Red Street 453", "Lodz", 2005),
                new Client("Adrain", "Kowalski", "Random Street 23", "Breslau", 1964),
                new Client("Konrad", "Starski", "Sweet Street 567", "Hong Kong", 1874),
                new Client("Stefan", "Jura", "Honey Street 31", "Radom", 2100)
            };

            TxtPROConverter txtcon = new TxtPROConverter();

            txtcon.writeClientsList(clients, "clients.txt");
            List <Client> deClients = txtcon.readClientsList("clients.txt");

            Assert.AreEqual(clients.Count, deClients.Count);
        }
Exemplo n.º 8
0
        public void TransactionObservableCollectionSerializationCountTXTTest()
        {
            ObservableCollection <Transaction> transactions = new ObservableCollection <Transaction>
            {
                new Transaction(1, 13, "5 wrzesnia"),
                new Transaction(45, 3, "8 wrzesnia"),
                new Transaction(4, 4, "30 wrzesnia"),
                new Transaction(7, 4, "45 wrzesnia"),
            };

            TxtPROConverter txtcon = new TxtPROConverter();

            txtcon.writeTransactionsObservableCollection(transactions, "transactions.txt");
            ObservableCollection <Transaction> deTransactions = txtcon.readTransactionsObservableCollection("transactions.txt");

            Assert.AreEqual(transactions.Count, deTransactions.Count);
        }
Exemplo n.º 9
0
        public void TransactionObservableCollectionSerializationTXTTest()
        {
            ObservableCollection <Transaction> transactions = new ObservableCollection <Transaction>
            {
                new Transaction(1, 13, "5 wrzesnia"),
                new Transaction(45, 3, "8 wrzesnia"),
                new Transaction(4, 4, "30 wrzesnia"),
                new Transaction(7, 4, "45 wrzesnia"),
            };

            TxtPROConverter txtcon = new TxtPROConverter();

            txtcon.writeTransactionsObservableCollection(transactions, "transactions.txt");
            ObservableCollection <Transaction> deTransactions = txtcon.readTransactionsObservableCollection("transactions.txt");

            for (int i = 0; i < transactions.Count; i++)
            {
                Assert.AreEqual(transactions[i].ToString(), deTransactions[i].ToString());
            }
        }