Esempio n. 1
0
        public void RegisterResource_NewResource_ResourceIsRegistered()
        {
            // Arrange
            string          registerName = "TestRegister";
            HttpContextBase context      = this.CreateHttpContext();
            var             register     = new ResourceRegister(registerName, context);

            string fakeResourceKey = "test-resource";

            Assert.IsTrue(register.GetInlineResources().Count(i => i == fakeResourceKey) == 0);

            // Act
            register.Register(fakeResourceKey);

            // Assert
            Assert.IsTrue(register.GetInlineResources().Count(i => i == fakeResourceKey) == 1);
        }
Esempio n. 2
0
        public void RegisterResource_AlreadyRegisteredResource_ExceptionIsThrown()
        {
            // Arrange
            string          registerName = "TestRegister";
            HttpContextBase context      = this.CreateHttpContext();
            var             register     = new ResourceRegister(registerName, context);

            string fakeResourceKey = "test-resource";

            register.Register(fakeResourceKey);
            Assert.IsTrue(register.GetInlineResources().Count(i => i == fakeResourceKey) == 1);

            // Act
            register.Register(fakeResourceKey, throwException: true);

            // Assert
            Assert.IsTrue(register.GetInlineResources().Count(i => i == fakeResourceKey) == 1);
        }
Esempio n. 3
0
        public void TryRegisterResource_AlreadyRegisteredResource_ResourceIsNotRegisteredTwice()
        {
            // Arrange
            string          registerName = "TestRegister";
            HttpContextBase context      = this.CreateHttpContext();
            var             register     = new ResourceRegister(registerName, context);

            string fakeResourceKey = "test-resource";

            register.Register(fakeResourceKey);
            Assert.IsTrue(register.GetInlineResources().Count(i => i == fakeResourceKey) == 1);

            // Act
            bool result = register.Register(fakeResourceKey);

            // Assert
            Assert.IsFalse(result);
            Assert.IsTrue(register.GetInlineResources().Count(i => i == fakeResourceKey) == 1);
        }