Пример #1
0
        public void IsTheBillJsonAvailable()
        {
            //Instantiate our home controller
            HomeController controller = new HomeController();

            //Attempt to download the bill
            string billJson = controller.DownloadBill();

            //Make sure the bill successfully downloaded
            Assert.IsNotNullOrEmpty(billJson);
        }
Пример #2
0
        public void IsTheBillFullyPopulated()
        {
            //Instantiate our home controller
            HomeController controller = new HomeController();

            //Attempt to download the bill
            string billJson = controller.DownloadBill();

            //Create an output exception, should return null if deserialization happened correctly
            JsonSerializationException serializationFailedException;

            //Attempt to deserialize the json into a Bill class
            Bill bill = controller.DeserializeJson(billJson, out serializationFailedException);

            //Bill Class Tests
            Assert.IsNotNull(bill.statement);
            Assert.IsNotNull(bill.package);
            Assert.IsNotNull(bill.callCharges);
            Assert.IsNotNull(bill.skyStore);

            //Statement Class Tests
            Assert.IsNotNull(bill.statement.generated);
            Assert.IsNotNull(bill.statement.due);
            Assert.IsNotNull(bill.statement.period);

            //Period Class Tests
            Assert.IsNotNull(bill.statement.period.from);
            Assert.IsNotNull(bill.statement.period.to);

            //Package Class Tests
            Assert.Greater(bill.package.subscriptions.Count, 0);

            //Subscription Class Tests
            Assert.That(bill.package.subscriptions.All(x => !string.IsNullOrWhiteSpace(x.type)));
            Assert.That(bill.package.subscriptions.All(x => !string.IsNullOrWhiteSpace(x.name)));

            //CallCharges Class Tests
            Assert.That(bill.callCharges.calls.All(x => !string.IsNullOrEmpty(x.called)));
            Assert.That(bill.callCharges.calls.All(x => !string.IsNullOrEmpty(x.duration.ToString())));

            //SkyStore Class Tests
            Assert.That(bill.skyStore.rentals.All(x => !string.IsNullOrWhiteSpace(x.title)));
            Assert.That(bill.skyStore.buyAndKeep.All(x => !string.IsNullOrWhiteSpace(x.title)));
        }
Пример #3
0
        public void IsTheBillValidJson()
        {
            //Instantiate our home controller
            HomeController controller = new HomeController();

            //Attempt to download the bill
            string billJson = controller.DownloadBill();

            //Create an output exception, should return null if deserialization happened correctly
            JsonSerializationException serializationFailedException;

            //Attempt to deserialize the json into a Bill class
            Bill bill = controller.DeserializeJson(billJson, out serializationFailedException);

            //Test whether the bill deserialized properly
            Assert.IsNotNull(bill, "The bill failed to deserialize properly");

            //Test whether an exception was thrown during deserialization
            Assert.IsNull(serializationFailedException);
        }
Пример #4
0
        public void IsTheLogFolderWriteable()
        {
            //Instantiate our home controller
            HomeController controller = new HomeController();

            var errorMessage = "CanWeWriteToTheLogFile Test Successful";

            controller.LogErrorMessage(errorMessage);

            //Set our folder and file variables
            string folderName = "../Log";
            string fileName = "CustomerBillErrorLog.txt";

            string fullFilePath = Path.Combine(folderName, fileName);

            Assert.IsTrue(Directory.Exists(folderName), string.Format("Folder ({0}) does not exist", folderName));
            Assert.IsTrue(File.Exists(fullFilePath), string.Format("File ({0}) was not written", fullFilePath));
        }