public void InProcDataCollectorLoadCoverlet()
        {
            var typeInfo = typeof(CoverletInProcDataCollector).GetTypeInfo();

            Assert.AreEqual("9.9.9.9", typeInfo.Assembly.GetName().Version.ToString());

            this.assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny <string>()))
            .Returns(typeInfo.Assembly);

            // We need to mock TestPluginCache because we have to create assembly resolver instance
            // using SetupAssemblyResolver method, we don't use any other method of class(like DiscoverTestExtensions etc...)
            // that fire creation
            TestableTestPluginCache testablePlugin = new TestableTestPluginCache();

            testablePlugin.SetupAssemblyResolver(typeInfo.Assembly.Location);

            this.inProcDataCollector = new InProcDataCollector(
                typeInfo.Assembly.Location,
                "Coverlet.Collector.DataCollection.CoverletInProcDataCollector, coverlet.collector, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
                typeof(InProcDataCollection).GetTypeInfo(),
                string.Empty,
                this.assemblyLoadContext.Object,
                testablePlugin);

            Assert.IsNotNull(this.inProcDataCollector.AssemblyQualifiedName);
            Assert.AreEqual(this.inProcDataCollector.AssemblyQualifiedName, typeInfo.AssemblyQualifiedName);
        }
Exemplo n.º 2
0
        public void InProcDataCollectorShouldNotThrowExceptionIfInvalidAssemblyIsProvided()
        {
            this.assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny <string>()))
            .Throws <FileNotFoundException>();

            this.inProcDataCollector = new InProcDataCollector(
                string.Empty,
                string.Empty,
                null,
                string.Empty,
                this.assemblyLoadContext.Object);

            Assert.AreEqual(this.inProcDataCollector.AssemblyQualifiedName, null);
        }
Exemplo n.º 3
0
        public void InProcDataCollectorShouldNotThrowExceptionIfAssemblyDoesNotContainAnyInProcDataCollector()
        {
            this.assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny <string>()))
            .Returns(Assembly.GetEntryAssembly());

            this.inProcDataCollector = new InProcDataCollector(
                string.Empty,
                string.Empty,
                null,
                string.Empty,
                this.assemblyLoadContext.Object);

            Assert.AreEqual(this.inProcDataCollector.AssemblyQualifiedName, null);
        }
Exemplo n.º 4
0
        public void InProcDataCollectorShouldInitializeIfAssemblyContainsAnyInProcDataCollector()
        {
            var typeInfo = typeof(TestableInProcDataCollector).GetTypeInfo();

            this.assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny <string>()))
            .Returns(typeInfo.Assembly);

            this.inProcDataCollector = new InProcDataCollector(
                string.Empty,
                typeInfo.AssemblyQualifiedName,
                typeInfo,
                string.Empty,
                this.assemblyLoadContext.Object);

            Assert.IsNotNull(this.inProcDataCollector.AssemblyQualifiedName);
            Assert.AreEqual(this.inProcDataCollector.AssemblyQualifiedName, typeInfo.AssemblyQualifiedName);
        }
        public void InProcDataCollectorLoadCoverlet()
        {
            var typeInfo = typeof(CoverletInProcDataCollector).GetTypeInfo();

            Assert.AreEqual("9.9.9.9", typeInfo.Assembly.GetName().Version.ToString());

            this.assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny <string>()))
            .Returns(typeInfo.Assembly);

            this.inProcDataCollector = new InProcDataCollector(
                typeInfo.Assembly.Location,
                "Coverlet.Collector.DataCollection.CoverletInProcDataCollector, coverlet.collector, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
                typeof(InProcDataCollection).GetTypeInfo(),
                string.Empty,
                this.assemblyLoadContext.Object);

            Assert.IsNotNull(this.inProcDataCollector.AssemblyQualifiedName);
            Assert.AreEqual(this.inProcDataCollector.AssemblyQualifiedName, typeInfo.AssemblyQualifiedName);
        }