@@ -516,7 +516,7 @@ public class Program { public static void Main() { } }
516516 }
517517
518518 [ Fact ]
519- public async Task ShouldSupportUnresolvedDependency ( )
519+ public async Task ShouldShowErrorWhenUnresolvedDependency ( )
520520 {
521521 // Given
522522
@@ -562,6 +562,62 @@ public class Program { public static void Main() { } }
562562
563563 // Then
564564 result . Success . ShouldBeFalse ( result ) ;
565+ result . Logs . Count ( i => i . Id == LogId . ErrorUnableToResolve ) . ShouldBe ( 1 , result ) ;
566+ result . Logs . Count ( i => i . Id == LogId . ErrorUnableToResolve && i . Location . GetSource ( ) == "abc" ) . ShouldBe ( 1 , result ) ;
567+ }
568+
569+ [ Fact ]
570+ public async Task ShouldShowMinimumNumbersOfErrorsWhenUnresolvedDependency ( )
571+ {
572+ // Given
573+
574+ // When
575+ var result = await """
576+ namespace Sample
577+ {
578+ using System;
579+ using Pure.DI;
580+ using Sample;
581+
582+ internal interface IService
583+ {
584+ }
585+
586+ internal interface IDependency
587+ {
588+ }
589+
590+ internal class Service : IService
591+ {
592+ internal Service(IDependency dependency, int id, string abc)
593+ {
594+ }
595+
596+ internal Service(int id, string abc)
597+ {
598+ }
599+ }
600+
601+ internal class Dependency : IDependency
602+ {
603+ public Dependency(int id, string abc) {}
604+ }
605+
606+ internal partial class Composition
607+ {
608+ void Setup() => Pure.DI.DI.Setup("Composition")
609+ .Bind<int>().To(_ => 99)
610+ .Bind<IDependency>().To<Dependency>()
611+ .Bind<IService>().To<Service>().Root<IService>("Root");
612+ }
613+
614+ public class Program { public static void Main() { } }
615+ }
616+ """ . RunAsync ( ) ;
617+
618+ // Then
619+ result . Success . ShouldBeFalse ( result ) ;
620+ result . Logs . Count ( i => i . Id == LogId . ErrorUnableToResolve ) . ShouldBe ( 1 , result ) ;
565621 result . Logs . Count ( i => i . Id == LogId . ErrorUnableToResolve && i . Location . GetSource ( ) == "abc" ) . ShouldBe ( 1 , result ) ;
566622 }
567623
0 commit comments