public void LoadJsonManifestFrom_ReturnsNullIfExceptionThrownFromResourceStream()
        {
            var mockLogger = new Mock <Logger>();

            Log.Default = mockLogger.Object;
            var mockException = new Exception(nameof(MockAssembly.ExceptionGetManifestResourceStream));

            Assert.IsNull(
                ManifestLoader.LoadJsonManifestFrom(
                    new MockAssembly
            {
                ExceptionGetManifestResourceStream = mockException,
                MockManifestResourceInfo           = new Dictionary <string, ManifestResourceInfo>
                {
                    {
                        @"manifest.json",
                        typeof(ManifestLoaderTest).Assembly.GetManifestResourceInfo(
                            $@"{VirtualTestManifest.Namespace}.manifest.lowercase.json"
                            )
                    }
                }
            }
                    )
                );

            mockLogger.Verify(l => l.Warn(mockException, "Failed to load manifest.json from MockAssembly."));
        }
        public void LoadJsonManifestFrom_ReturnsNullIfStreamIsEmpty()
        {
            var mockLogger = new Mock <Logger>();

            Log.Default = mockLogger.Object;
            var mockException = new InvalidDataException("Manifest is empty or failed to load and is null.");

            Assert.IsNull(
                ManifestLoader.LoadJsonManifestFrom(
                    new MockAssembly
            {
                MockManifestResourceInfo = new Dictionary <string, ManifestResourceInfo>
                {
                    {
                        @"manifest.json",
                        typeof(ManifestLoaderTest).Assembly.GetManifestResourceInfo(
                            $@"{VirtualTestManifest.Namespace}.manifest.lowercase.json"
                            )
                    }
                },
                MockManifestResourceStream = new Dictionary <string, Stream>
                {
                    { @"manifest.json", new MemoryStream() }
                }
            }
                    )
                );

            mockLogger.Verify(
                l => l.Warn(
                    It.Is <InvalidDataException>(e => e.Message == mockException.Message),
                    "Failed to load manifest.json from MockAssembly."
                    )
                );
        }
        public void LoadJsonManifestFrom_ReturnsNullIfExceptionThrownFromResourceInfo()
        {
            var mockLogger = new Mock <Logger>();

            Log.Default = mockLogger.Object;
            var mockException = new Exception(nameof(MockAssembly.ExceptionGetManifestResourceInfo));

            Assert.IsNull(
                ManifestLoader.LoadJsonManifestFrom(
                    new MockAssembly
            {
                ExceptionGetManifestResourceInfo = mockException
            }
                    )
                );

            mockLogger.Verify(l => l.Warn(mockException, "Failed to load manifest.json from MockAssembly."));
        }
 public void LoadJsonManifestFrom_ReturnsNullIfNoManifest()
 {
     Assert.IsNull(ManifestLoader.LoadJsonManifestFrom(new MockAssembly()));
 }