Пример #1
0
        public void log_a_duplicate_assembly()
        {
            var package = new StubBottle("a");
            diagnostics.LogDuplicateAssembly(package, "Duplicate.Assembly");

            diagnostics.LogFor(package).FullTraceText().ShouldContain("Assembly 'Duplicate.Assembly' was ignored because it is already loaded");
        }
Пример #2
0
        public void load_duplicate_assembly_attempt_from_file_for_a_new_assembly()
        {
            var assembly = Assembly.GetExecutingAssembly();
            var package1 = new StubBottle("something")
            {
                LoadingAssemblies = x => x.Use(assembly)
            };

            ClassUnderTest.LoadAssembliesFromPackage(package1);

            var assemblyFileLoader = MockFor <Func <string, Assembly> >();

            ClassUnderTest.AssemblyFileLoader = assemblyFileLoader;

            var theAssemblyName = assembly.GetName().Name;
            var package         = new StubBottle("something")
            {
                LoadingAssemblies = x => x.LoadFromFile("filename.dll", theAssemblyName)
            };

            assemblyFileLoader.Expect(x => x.Invoke("filename.dll")).Return(assembly);

            ClassUnderTest.LoadAssembliesFromPackage(package);

            MockFor <IBottlingDiagnostics>().AssertWasCalled(x => x.LogDuplicateAssembly(package, theAssemblyName));


            ClassUnderTest.Assemblies.Count.ShouldEqual(1);
        }
Пример #3
0
        public void log_a_duplicate_assembly()
        {
            var package = new StubBottle("a");

            diagnostics.LogDuplicateAssembly(package, "Duplicate.Assembly");

            diagnostics.LogFor(package).FullTraceText().ShouldContain("Assembly 'Duplicate.Assembly' was ignored because it is already loaded");
        }
Пример #4
0
        public void SetUp()
        {
            diagnostics = new BottlingDiagnostics(new LoggingSession());
            _bottle     = new StubBottle("a");
            assembly    = Assembly.GetExecutingAssembly();

            theProvenance = "from here";
            diagnostics.LogAssembly(_bottle, assembly, theProvenance);
        }
Пример #5
0
        public void SetUp()
        {
            diagnostics = new BottlingDiagnostics(new LoggingSession());

            loader  = new StubPackageLoader("a", "b");
            _bottle = new StubBottle("a");

            diagnostics.LogPackage(_bottle, loader);
        }
Пример #6
0
        //helpers
        private StubBottle hasPackage(string name)
        {
            var x = new StubBottle(name);

            if (thePackages.Any(p => p.Name.Equals(x.Name)))
            {
                return(thePackages.First(p => p.Name.Equals(name)));
            }

            thePackages.Add(x);
            Services.Inject <IPackageInfo>(x);
            return(x);
        }
Пример #7
0
        public void log_an_assembly_failure()
        {
            var package = new StubBottle("a");
            var exception = new ApplicationException("didn't work");
            var theFileNameOfTheAssembly = "assembly.dll";
            diagnostics.LogAssemblyFailure(package, theFileNameOfTheAssembly, exception);

            var log = diagnostics.LogFor(package);

            log.Success.ShouldBeFalse();
            log.FullTraceText().Contains(exception.ToString()).ShouldBeTrue();

            log.FullTraceText().ShouldContain("Failed to load assembly at '{0}'".ToFormat(theFileNameOfTheAssembly));
        }
Пример #8
0
        public void log_an_assembly_failure()
        {
            var package   = new StubBottle("a");
            var exception = new ApplicationException("didn't work");
            var theFileNameOfTheAssembly = "assembly.dll";

            diagnostics.LogAssemblyFailure(package, theFileNameOfTheAssembly, exception);

            var log = diagnostics.LogFor(package);

            log.Success.ShouldBeFalse();
            log.FullTraceText().Contains(exception.ToString()).ShouldBeTrue();

            log.FullTraceText().ShouldContain("Failed to load assembly at '{0}'".ToFormat(theFileNameOfTheAssembly));
        }
Пример #9
0
        public void log_successful_registration_of_an_assembly()
        {
            var assembly = Assembly.GetExecutingAssembly();

            var package = new StubBottle("something")
            {
                LoadingAssemblies = x => x.Use(assembly)
            };

            ClassUnderTest.LoadAssembliesFromPackage(package);

            MockFor <IBottlingDiagnostics>().AssertWasCalled(x => x.LogAssembly(package, assembly, AssemblyLoader.DIRECTLY_REGISTERED_MESSAGE));


            ClassUnderTest.Assemblies.Contains(assembly).ShouldBeTrue();
        }
Пример #10
0
        public void find_children()
        {
            var log = new PackageLog();

            var loader1 = new StubBottleLoader();
            var loader2 = new StubBottleLoader();
            var loader3 = new StubBottleLoader();

            var package1 = new StubBottle("1");
            var package2 = new StubBottle("2");
            var package3 = new StubBottle("3");

            log.AddChild(loader1, loader2, loader3, package1, package2, package3);

            log.FindChildren<IBottleLoader>().ShouldHaveTheSameElementsAs(loader1, loader2, loader3);

            log.FindChildren<IPackageInfo>().ShouldHaveTheSameElementsAs(package1, package2, package3);
        }
Пример #11
0
        public void find_children()
        {
            var log = new PackageLog();

            var loader1 = new StubPackageLoader();
            var loader2 = new StubPackageLoader();
            var loader3 = new StubPackageLoader();

            var package1 = new StubBottle("1");
            var package2 = new StubBottle("2");
            var package3 = new StubBottle("3");

            log.AddChild(loader1, loader2, loader3, package1, package2, package3);

            log.FindChildren <IPackageLoader>().ShouldHaveTheSameElementsAs(loader1, loader2, loader3);

            log.FindChildren <IPackageInfo>().ShouldHaveTheSameElementsAs(package1, package2, package3);
        }
Пример #12
0
        public void load_unsuccessfully_from_file_for_a_new_assembly()
        {
            var assemblyFileLoader = MockFor <Func <string, Assembly> >();

            ClassUnderTest.AssemblyFileLoader = assemblyFileLoader;

            var package = new StubBottle("something")
            {
                LoadingAssemblies = x => x.LoadFromFile("filename.dll", "AssemblyName")
            };

            var theExceptionFromAssemblyLoading = new ApplicationException("You shall not pass!");

            assemblyFileLoader.Expect(x => x.Invoke("filename.dll")).Throw(theExceptionFromAssemblyLoading);

            ClassUnderTest.LoadAssembliesFromPackage(package);

            MockFor <IBottlingDiagnostics>().AssertWasCalled(x => x.LogAssemblyFailure(package, "filename.dll", theExceptionFromAssemblyLoading));
        }
Пример #13
0
        public void log_duplicate_registration_of_an_assembly()
        {
            var assembly = Assembly.GetExecutingAssembly();

            var package1 = new StubBottle("something")
            {
                LoadingAssemblies = x => x.Use(assembly)
            };

            var package2 = new StubBottle("something")
            {
                LoadingAssemblies = x => x.Use(assembly)
            };

            ClassUnderTest.LoadAssembliesFromPackage(package1);
            ClassUnderTest.LoadAssembliesFromPackage(package2);

            MockFor <IBottlingDiagnostics>().AssertWasCalled(x => x.LogDuplicateAssembly(package2, assembly.FullName));
        }
Пример #14
0
        public void load_successfully_from_file_for_a_new_assembly()
        {
            var assembly = Assembly.GetExecutingAssembly();

            var assemblyFileLoader = MockFor <Func <string, Assembly> >();

            ClassUnderTest.AssemblyFileLoader = assemblyFileLoader;

            var package = new StubBottle("something")
            {
                LoadingAssemblies = x => x.LoadFromFile("filename.dll", "AssemblyName")
            };

            assemblyFileLoader.Expect(x => x.Invoke("filename.dll")).Return(assembly);

            ClassUnderTest.LoadAssembliesFromPackage(package);

            MockFor <IBottlingDiagnostics>().AssertWasCalled(x => x.LogAssembly(package, assembly, "Loaded from filename.dll"));
            assemblyFileLoader.VerifyAllExpectations();

            ClassUnderTest.Assemblies.Contains(assembly).ShouldBeTrue();
        }
Пример #15
0
        public void SetUp()
        {
            diagnostics = new BottlingDiagnostics(new LoggingSession());

            loader = new StubBottleLoader("a", "b");
            _bottle = new StubBottle("a");

            diagnostics.LogPackage(_bottle, loader);
        }
Пример #16
0
        public void SetUp()
        {
            diagnostics = new BottlingDiagnostics(new LoggingSession());
            _bottle = new StubBottle("a");
            assembly = Assembly.GetExecutingAssembly();

            theProvenance = "from here";
            diagnostics.LogAssembly(_bottle, assembly, theProvenance);
        }