public void Get_GivenOpenFuncWhichReturnsNull_ThrowsInternalErrorException()
        {
            string projectFile = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo";

            ProjectRootElement OpenFunc(string pathArg, ProjectRootElementCacheBase cacheArg) => null;

            var cache = new SimpleProjectRootElementCache();

            Should.Throw <InternalErrorException>(() =>
            {
                cache.Get(projectFile, OpenFunc, false, null);
            });
        }
        public void Get_GivenCachedProjectFileWithDifferentCasing_ReturnsRootElement()
        {
            string             projectFile        = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo";
            string             projectFileToCache = NativeMethodsShared.IsUnixLike ? "/Foo" : "c:\\Foo";
            ProjectRootElement rootElementToCache = ProjectRootElement.Create(projectFileToCache);

            var cache = new SimpleProjectRootElementCache();

            cache.AddEntry(rootElementToCache);

            ProjectRootElement actualRootElement = cache.Get(projectFile, null, false, null);

            actualRootElement.ShouldBe(rootElementToCache);
        }
        public void Get_GivenOpenFuncWhichDoesNotAddToCache_ThrowsInternalErrorException()
        {
            string             projectFile     = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo";
            string             openFuncPath    = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo";
            ProjectRootElement openFuncElement = ProjectRootElement.Create(openFuncPath);

            ProjectRootElement OpenFunc(string pathArg, ProjectRootElementCacheBase cacheArg) => openFuncElement;

            var cache = new SimpleProjectRootElementCache();

            Should.Throw <InternalErrorException>(() =>
            {
                cache.Get(projectFile, OpenFunc, false, null);
            });
        }
        public void Get_GivenOpenFuncWhichReturnsIncorrectProject_ThrowsInternalErrorException()
        {
            string             projectFile        = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo";
            string             projectFileToCache = NativeMethodsShared.IsUnixLike ? "/bar" : "c:\\bar";
            ProjectRootElement rootElementToCache = ProjectRootElement.Create(projectFileToCache);

            ProjectRootElement OpenFunc(string pathArg, ProjectRootElementCacheBase cacheArg)
            {
                return(rootElementToCache);
            }

            var cache = new SimpleProjectRootElementCache();

            Should.Throw <InternalErrorException>(() =>
            {
                cache.Get(projectFile, OpenFunc, false, null);
            });
        }
        public void Get_GivenOpenFuncWhichAddsRootElementWithDifferentCasing_ReturnsRootElement()
        {
            string             projectFile        = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo";
            string             projectFileToCache = NativeMethodsShared.IsUnixLike ? "/Foo" : "c:\\Foo";
            ProjectRootElement rootElementToCache = ProjectRootElement.Create(projectFileToCache);

            ProjectRootElement OpenFunc(string pathArg, ProjectRootElementCacheBase cacheArg)
            {
                return(rootElementToCache);
            }

            var cache = new SimpleProjectRootElementCache();

            cache.AddEntry(rootElementToCache);

            ProjectRootElement actualRootElement = cache.Get(projectFile, OpenFunc, false, null);

            actualRootElement.ShouldBe(rootElementToCache);
        }