public void CreateInstance_AdditionalParameter_NotSupported()
        {
            var serviceProvider = new FakeServiceProvider();

            var activator = new CoconaLiteInstanceActivator();
            var ex        = Assert.Throws <NotSupportedException>(() => activator.CreateInstance(serviceProvider, typeof(CreateInstance_NoAdditionalParameter_Target), new object[] { 123, "Hello Konnichiwa!" }));
        }
        public void CreateInstance_Insufficient()
        {
            var serviceProvider = new FakeServiceProvider();

            var activator = new CoconaLiteInstanceActivator();
            var ex        = Assert.Throws <InvalidOperationException>(() => activator.CreateInstance(serviceProvider, typeof(CreateInstance_NoAdditionalParameter_Target), Array.Empty <object>()));

            ex.Message.Should().Be("Unable to resolve service for type 'System.String' while attempting to activate 'Cocona.Lite.Test.CoconaLiteInstanceActivatorTest+CreateInstance_NoAdditionalParameter_Target'");
        }
        public void CreateInstance_NoAdditionalParameter()
        {
            var serviceProvider = new FakeServiceProvider();

            serviceProvider.ValueByType[typeof(int)]    = 123;
            serviceProvider.ValueByType[typeof(string)] = "Hello Konnichiwa!";

            var activator = new CoconaLiteInstanceActivator();
            var obj       = activator.CreateInstance(serviceProvider, typeof(CreateInstance_NoAdditionalParameter_Target), Array.Empty <object>());

            obj.Should().BeOfType <CreateInstance_NoAdditionalParameter_Target>();
            ((CreateInstance_NoAdditionalParameter_Target)obj).Value0.Should().Be("Hello Konnichiwa!");
            ((CreateInstance_NoAdditionalParameter_Target)obj).Value1.Should().Be(123);
        }