Esempio n. 1
0
        public void GetNamespaces_ExceptionThrown_InternalServerError()
        {
            var mock = new Mock <ICacheService>();

            mock.Setup(s => s.GetNamespaces()).Throws <Exception>();
            var controller = new CacheController(mock.Object);

            controller.GetNamespaces();
        }
Esempio n. 2
0
        public void GetNamespaces_EmptyCollection_EmptyCollectionReturned()
        {
            var mock = new Mock <ICacheService>();

            mock.Setup(s => s.GetNamespaces()).Returns(new string[] { });
            var controller = new CacheController(mock.Object);

            var result = controller.GetNamespaces();

            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.Count());
        }
Esempio n. 3
0
        public void GetNamespaces_ThreeElements_CollectionReturned()
        {
            var mock = new Mock <ICacheService>();

            mock.Setup(s => s.GetNamespaces()).Returns(new string[] { "namespace1", "namespace2", "namespace3" });
            var controller = new CacheController(mock.Object);

            var result = controller.GetNamespaces();

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Count());
            Assert.AreEqual("namespace1", result.ElementAt(0).Namespace);
            Assert.AreEqual("namespace2", result.ElementAt(1).Namespace);
            Assert.AreEqual("namespace3", result.ElementAt(2).Namespace);
        }