Example #1
0
        public void FontLoader_GenerateFontFromDescriptionInfoFailsOnNullDescription_ReturnsNull()
        {
            var appAssembly       = Substitute.For <IApplicationAssembly>();
            var fontsAssembly     = Substitute.For <IFontsAssembly>();
            var filesystem        = Substitute.For <IFileSystem>();
            var messenger         = Substitute.For <IFrameworkMessenger>();
            var properties        = Substitute.For <IStartupPropertiesCache>();
            var gpuSurfaceManager = Substitute.For <IGpuSurfaceManager>();
            var subFontGenerator  = Substitute.For <ISubFontGenerator>();

            IFontLoader loader = new FontLoader(
                appAssembly,
                fontsAssembly,
                messenger,
                gpuSurfaceManager,
                properties,
                subFontGenerator,
                filesystem);

            Assert.Null(loader.GenerateFontFromDescriptionInfo(null));
        }
Example #2
0
        public void FontLoader_GenerateFontFromDescriptionInfo_CallsGeneratorEnoughTimes()
        {
            var appAssembly   = Substitute.For <IApplicationAssembly>();
            var fontsAssembly = Substitute.For <IFontsAssembly>();
            var filesystem    = Substitute.For <IFileSystem>();

            var messenger         = Substitute.For <IFrameworkMessenger>();
            var properties        = Substitute.For <IStartupPropertiesCache>();
            var gpuSurfaceManager = Substitute.For <IGpuSurfaceManager>();

            var subFontGeneratorMock = Substitute.For <ISubFontGenerator>();

            subFontGeneratorMock.Generate(Arg.Any <CandidateSubFontDesc>()).Returns(new SubFont(0, 0, new Dictionary <char, FontCharacter>(), new ITexture[3], false, null));

            IFontLoader loader = new FontLoader(
                appAssembly,
                fontsAssembly,
                messenger,
                gpuSurfaceManager,
                properties,
                subFontGeneratorMock,
                filesystem);

            var result = loader.GenerateFontFromDescriptionInfo(new CandidateFontDesc
            {
                CandidateSubFonts = new List <CandidateSubFontDesc>
                {
                    new CandidateSubFontDesc(),
                    new CandidateSubFontDesc(),
                    new CandidateSubFontDesc()
                }
            });

            subFontGeneratorMock.Received(3).Generate(Arg.Any <CandidateSubFontDesc>());

            Assert.NotNull(result);
        }