Exemplo n.º 1
0
        public void PassedTest(bool?passed)
        {
            var s = new Status(_mockCheck1.Object, passed, SeverityLevel.Error, TimeSpan.FromMilliseconds(5), "hello", null, null,
                               null);
            var c = new SystemStatusModel.Check(s);

            Assert.AreEqual(passed, c.Passed);
            var ssm = new SystemStatusModel(new [] { s });

            Assert.AreEqual(passed.GetValueOrDefault(true), ssm.NoFailures);
        }
Exemplo n.º 2
0
        public void ExceptionTest()
        {
            var s = new Status(_mockCheck1.Object, false, SeverityLevel.Error, TimeSpan.FromMilliseconds(5), "hello",
                               new Exception("Failure"),
                               null, null);
            var c = new SystemStatusModel.Check(s);

            Assert.NotNull(c.Exception);
            var json = c.ToJson();

            Console.WriteLine(json);
            Assert.AreEqual(File.ReadAllText($"{AppDomain.CurrentDomain.BaseDirectory}\\Exception.json"), json);
            var objFromJson = json.FromJsonTo <SystemStatusModel.Check>();

            Assert.NotNull(objFromJson);
            Assert.AreEqual(json, objFromJson.ToJson());
        }
Exemplo n.º 3
0
        public void PayloadTest()
        {
            var s = new Status(_mockCheck1.Object, false, SeverityLevel.Error, TimeSpan.FromMilliseconds(5), "hello", null,
                               null,
                               new dynamic[] { new { Foo = "bar", Count = 42 }, new { Foo = "tar", Count = 43 } });
            var c = new SystemStatusModel.Check(s);

            Assert.NotNull(c.Payload);
            var json = c.ToJson();

            Console.WriteLine(json);
            Assert.AreEqual(File.ReadAllText($"{AppDomain.CurrentDomain.BaseDirectory}\\Payload.json"), json);
            var objFromJson = json.FromJsonTo <SystemStatusModel.Check>();

            Assert.NotNull(objFromJson);
            Assert.AreEqual(json, objFromJson.ToJson());
        }
Exemplo n.º 4
0
        public void ReactionsTest()
        {
            var s = new Status(_mockCheck1.Object, false, SeverityLevel.Error, TimeSpan.FromMilliseconds(5), "hello", null,
                               new[]
            {
                new Reaction
                {
                    Method            = "GET", Payload = @"{""a"" : 1}", Url = "http://google.com",
                    VisualDescription = "hello1"
                }
            },
                               null);
            var c = new SystemStatusModel.Check(s);

            Assert.AreEqual(1, c.Reactions.Count());
            var json = c.ToJson();

            Console.WriteLine(json);
            Assert.AreEqual(File.ReadAllText($"{AppDomain.CurrentDomain.BaseDirectory}\\Reaction.json"), json);
            var objFromJson = json.FromJsonTo <SystemStatusModel.Check>();

            Assert.NotNull(objFromJson);
            Assert.AreEqual(json, objFromJson.ToJson());
        }