Exemple #1
0
        public void SearchingBookTestbyName(string Name)
        {
            AssetInformation book = new AssetInformation();

            using (StreamReader r = new StreamReader("SearchAsset.json"))
            {
                AssetInformation        actualName = new AssetInformation();
                string                  json       = r.ReadToEnd();
                List <AssetInformation> items      = JsonConvert.DeserializeObject <List <AssetInformation> >(json);
                items.Add(actualName);
                dynamic array = JsonConvert.DeserializeObject(json);
                foreach (var item in array)
                {
                    Console.WriteLine("{0} {1} {2}", item.Id, item.Name, item.Year);
                }
                AssetHelper.SearchAsset();
                if (actualName.Name == Name)
                {
                    Assert.Equal(book.Name, actualName.Name);
                }
                else
                {
                    Assert.NotEqual(book.Name, actualName.Name);
                }
            }
        }
Exemple #2
0
        public void CheckingAddAssetListTest()
        {
            AssetInformation asset = new AssetInformation()
            {
                Id   = 12,
                Name = "jyothi",
                Year = 1998
            };
            var mockInfo = new Mock <AssetInformation>();

            using (StreamReader r = new StreamReader("SearchAsset.json"))
            {
                AssetInformation        item1 = new AssetInformation();
                string                  json  = r.ReadToEnd();
                List <AssetInformation> items = JsonConvert.DeserializeObject <List <AssetInformation> >(json);
                items.Add(item1);
                dynamic array = JsonConvert.DeserializeObject(json);
                foreach (var item in array)
                {
                    Console.WriteLine("{0} {1} {2}", item.Id, item.Name, item.Year);
                }
                AssetHelper.AddAsset(mockInfo.Object);
                Assert.Equal(asset, item1);
            }
        }
Exemple #3
0
        public void SearchingHardwareTestbyId(int id)
        {
            AssetInformation hardware = new AssetInformation();

            using (StreamReader r = new StreamReader("SearchAsset.json"))
            {
                AssetInformation        actualId = new AssetInformation();
                string                  json     = r.ReadToEnd();
                List <AssetInformation> items    = JsonConvert.DeserializeObject <List <AssetInformation> >(json);
                items.Add(actualId);
                dynamic array = JsonConvert.DeserializeObject(json);
                foreach (var item in array)
                {
                    Console.WriteLine("{0} {1} {2}", item.Id, item.Name, item.Year);
                }
                AssetHelper.SearchAsset();
                if (actualId.Id == id)
                {
                    Assert.Equal(hardware.Id, actualId.Id);
                }
                else
                {
                    Assert.NotEqual(hardware.Id, actualId.Id);
                }
            }
        }
        public static void AddAsset(AssetInformation info)
        {
            Console.WriteLine("Enter how many records you want records:");
            int noOfRecords = Convert.ToInt32(Console.ReadLine());

            for (int item = 0; item < noOfRecords; item++)
            {
                AssetInformation asset = new AssetInformation();
                Console.WriteLine("Enter Id");
                int id = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter name");
                string name = Console.ReadLine();
                Console.WriteLine("Enter year");
                int year = Convert.ToInt32(Console.ReadLine());
                asset.Id   = id;
                asset.Name = name;
                asset.Year = year;
                assetList.Add(asset);
                // string jsonString = JsonSerializer.Serialize(asset);
                // jsonString = JsonSerializer.Serialize(asset);
                // File.WriteAllText(@"asset.json", jsonString);
                // Console.WriteLine("stored");
            }
            Console.WriteLine("Id\tName\tyear\t");
            assetList.ForEach((AssetInformation) => Console.WriteLine("{0}\t{1}\t{2}", AssetInformation.Id, AssetInformation.Name, AssetInformation.Year));
        }
Exemple #5
0
            // To Add the information into Assets
            public static void AddAsset()
            {
                Console.WriteLine("Enter how many records you want records:");
                int noOfRecords = Convert.ToInt32(Console.ReadLine());

                for (int item = 0; item < noOfRecords; item++)
                {
                    AssetInformation obj = new AssetInformation();
                    Console.WriteLine("Enter Id");
                    int id = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Enter name");
                    string name = Console.ReadLine();
                    Console.WriteLine("Enter year");
                    int year = Convert.ToInt32(Console.ReadLine());
                    obj.Id   = id;
                    obj.Name = name;
                    obj.Year = year;
                    assetList.Add(obj);
                }
                Console.WriteLine("Id\tName\tyear\t");
                assetList.ForEach((AssetInformation) => Console.WriteLine("{0}\t{1}\t{2}", AssetInformation.Id, AssetInformation.Name, AssetInformation.Year));
            }