public void AssignVirtualPathToPrivateField_WhenClassIsConstructed()
        {
            string virtualPath = "~/page.aspx";
            var resourceProvider = new LocalResourceProvider2(virtualPath);

            var fieldInfo = resourceProvider.GetType().GetField("virtualPath", BindingFlags.Instance | BindingFlags.NonPublic);
            var fieldValue = fieldInfo.GetValue(resourceProvider);
            Assert.AreEqual(virtualPath, fieldValue.ToString());
        }
        public void AssignResolverFieldToDefaultResolver_WhenConstructorWithoutResolverHasBeenCalled()
        {
            string virtualPath = "~/page.aspx";
            var resourceProvider = new LocalResourceProvider2(virtualPath);

            var fieldInfo = resourceProvider.GetType().GetField("resourceFileResolver", BindingFlags.Instance | BindingFlags.NonPublic);
            var fieldValue = fieldInfo.GetValue(resourceProvider);

            Assert.IsNotNull(fieldValue);
            Assert.IsInstanceOfType(fieldValue, typeof(ResourceFileResolver));
        }
        public void RetrieveTheObjectForTheExistingKeyAndInvariantCulture()
        {
            var resourceFileResolverMock = new ResourceFileResolverMock(new string[]
            {
                "Page1.aspx.resx",
                "Page1.aspx.bg.resx",
                "Page1.aspx.hr-HR.resx"
            });
            var resourceProvider = new LocalResourceProvider2("Page1.aspx", resourceFileResolverMock);

            Assert.AreEqual("Hello universe!", resourceProvider.GetObject("Label2.Text", CultureInfo.InvariantCulture));
            Assert.AreEqual("Hello world!", resourceProvider.GetObject("Literal1.Text", CultureInfo.InvariantCulture));
        }
 public void ThrowAnException_WhenGetObjectIsCalledWithNoKeySpecified()
 {
     var resourceProvider = new LocalResourceProvider2("~/Page1.aspx");
     try
     {
         resourceProvider.GetObject(string.Empty, CultureInfo.InvariantCulture);
         Assert.Fail("ArgumentNullException was supposed to be thrown.");
     }
     catch (ArgumentNullException ex)
     {
         Assert.AreEqual("resourceKey", ex.ParamName);
     }
 }
        public void ThrowAnException_WhenGetImplicitResourceKeysIsCalledAndKeyPrefixIsNull()
        {
            var localResourceProvider = new LocalResourceProvider2("~/file");

            try
            {
                localResourceProvider.GetImplicitResourceKeys(null);
                Assert.Fail("ArgumentNullException was supposed to be thrown.");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("keyPrefix", ex.ParamName);
            }
        }
 public void ThrowAnException_WhenClassIsConstructedWithoutAVirtualPath()
 {
     try
     {
         var resourceProvider = new LocalResourceProvider2(null);
         Assert.Fail("ArgumentNullException was supposed to be thrown.");
     }
     catch (ArgumentNullException ex)
     {
         Assert.AreEqual("virtualPath", ex.ParamName);
     }
 }