public void MultiplyDeclaredCollectionsRaisesEnvironmentalWarning()
    {
        var broker   = Substitute.For <IMessageAggregator>();
        var testType = Mocks.TypeInfo("type", attributes: new[] { Mocks.CollectionAttribute("This is a test collection") });
        var collectionDefinition1 = Mocks.TypeInfo("collectionDefinition1", attributes: new[] { Mocks.CollectionDefinitionAttribute("This is a test collection") });
        var collectionDefinition2 = Mocks.TypeInfo("collectionDefinition2", attributes: new[] { Mocks.CollectionDefinitionAttribute("This is a test collection") });
        var assembly = Mocks.TestAssembly(@"C:\Foo\bar.dll", types: new[] { collectionDefinition1, collectionDefinition2 });
        var factory  = new CollectionPerAssemblyTestCollectionFactory(assembly, broker);

        factory.Get(testType);

        var captured = broker.Captured(b => b.Add <EnvironmentalWarning>(null));
        var warning  = captured.Arg <EnvironmentalWarning>();

        Assert.Equal("Multiple test collections declared with name 'This is a test collection': collectionDefinition1, collectionDefinition2", warning.Message);
    }
Beispiel #2
0
    public static void MultiplyDeclaredCollectionsRaisesEnvironmentalWarning()
    {
        var messages = new List <IMessageSinkMessage>();
        var spy      = SpyMessageSink.Create(messages: messages);
        var testType = Mocks.TypeInfo("type", attributes: new[] { Mocks.CollectionAttribute("This is a test collection") });
        var collectionDefinition1 = Mocks.TypeInfo("collectionDefinition1", attributes: new[] { Mocks.CollectionDefinitionAttribute("This is a test collection") });
        var collectionDefinition2 = Mocks.TypeInfo("collectionDefinition2", attributes: new[] { Mocks.CollectionDefinitionAttribute("This is a test collection") });
        var assembly = Mocks.TestAssembly(@"C:\Foo\bar.dll", types: new[] { collectionDefinition1, collectionDefinition2 });
        var factory  = new CollectionPerAssemblyTestCollectionFactory(assembly, spy);

        factory.Get(testType);

        Assert.Collection(messages.OfType <IDiagnosticMessage>().Select(m => m.Message),
                          msg => Assert.Equal("Multiple test collections declared with name 'This is a test collection': collectionDefinition1, collectionDefinition2", msg)
                          );
    }
    public void UsingTestCollectionDefinitionSetsTypeInfo()
    {
        var testType = Mocks.TypeInfo("type", attributes: new[] { Mocks.CollectionAttribute("This is a test collection") });
        var collectionDefinitionType = Mocks.TypeInfo("collectionDefinition", attributes: new[] { Mocks.CollectionDefinitionAttribute("This is a test collection") });
        var assembly = Mocks.TestAssembly(@"C:\Foo\bar.dll", types: new[] { collectionDefinitionType });
        var factory  = new CollectionPerAssemblyTestCollectionFactory(assembly);

        var result = factory.Get(testType);

        Assert.Same(collectionDefinitionType, result.CollectionDefinition);
    }
Beispiel #4
0
    public static void MultiplyDeclaredCollectionsRaisesEnvironmentalWarning()
    {
        var spy = SpyMessageSink.Capture();

        TestContext.Current !.DiagnosticMessageSink = spy;
        var testType = Mocks.TypeInfo("type", attributes: new[] { Mocks.CollectionAttribute("This is a test collection") });
        var collectionDefinition1 = Mocks.TypeInfo("collectionDefinition1", attributes: new[] { Mocks.CollectionDefinitionAttribute("This is a test collection") });
        var collectionDefinition2 = Mocks.TypeInfo("collectionDefinition2", attributes: new[] { Mocks.CollectionDefinitionAttribute("This is a test collection") });
        var assembly = Mocks.TestAssembly(@"C:\Foo\bar.dll", types: new[] { collectionDefinition1, collectionDefinition2 });
        var factory  = new CollectionPerClassTestCollectionFactory(assembly);

        factory.Get(testType);

        var msg = Assert.Single(spy.Messages.OfType <_DiagnosticMessage>().Select(m => m.Message));

        Assert.Equal("Multiple test collections declared with name 'This is a test collection': collectionDefinition1, collectionDefinition2", msg);
    }