示例#1
0
        public void KnownInvalid()
        {
            Assembly asm = Assembly.GetExecutingAssembly();

            Stream xmlStream = asm.GetManifestResourceStream("JamesRiverLevel.Tests.XML.invalid.xml");

            var test = NWS.GetRiverInformation(xmlStream);

            Assert.IsNull(test);
        }
示例#2
0
        public void None()
        {
            Assembly asm = Assembly.GetExecutingAssembly();

            Stream xmlStream = asm.GetManifestResourceStream("JamesRiverLevel.Tests.XML.good.xml");

            var test      = NWS.GetRiverInformation(xmlStream);
            var viewModel = NWS.Parse(test);

            Assert.AreEqual(WaterLevelAction.None, viewModel.ActionLevel);
        }
示例#3
0
        public void KnownGoodXML()
        {
            Assembly asm = Assembly.GetExecutingAssembly();

            Stream xmlStream = asm.GetManifestResourceStream("JamesRiverLevel.Tests.XML.good.xml");

            var test = NWS.GetRiverInformation(xmlStream);

            Assert.IsNotNull(test);
            Assert.AreEqual(test.id, "RMDV2");
        }
示例#4
0
        public void Permit()
        {
            Assembly asm = Assembly.GetExecutingAssembly();

            Stream xmlStream = asm.GetManifestResourceStream("JamesRiverLevel.Tests.XML.permit.xml");

            var test = NWS.GetRiverInformation(xmlStream);

            var viewModel = NWS.Parse(test);

            Assert.AreEqual(WaterLevelAction.Permit, viewModel.ActionLevel);
            Assert.AreEqual(9.0f, viewModel.WaterLevel);
            Assert.AreEqual("ft", viewModel.WaterLevelUnit);
        }
        public ActionResult Index()
        {
            if (HttpContext.Application["ViewModel"] == null ||
                ((DisplayViewModel)HttpContext.Application["ViewModel"]).DataObtainedAt.AddSeconds(300)
                < DateTime.Now)
            {
                var results = NWS.GetRiverInformation();

                var viewModel = NWS.Parse(results);

                HttpContext.Application["ViewModel"] = viewModel;
            }

            return(HttpContext.Application["ViewModel"] == null?View("Error") : View(HttpContext.Application["ViewModel"]));
        }
示例#6
0
        public void InvalidObject()
        {
            var test = NWS.Parse(null);

            Assert.IsNull(test);
        }
示例#7
0
        public void BlankXML()
        {
            var test = NWS.GetRiverInformation(new MemoryStream(Encoding.Default.GetBytes(String.Empty)));

            Assert.IsNull(test);
        }