public void GetInstanceOfClassWithConstructorThatContainsParameters() { var container = new ContainerAdamIoC(); container.RegisterImplementation <ICompany, Company>(); container.RegisterImplementation <IContactInformation, ContactInformation>(); container.RegisterImplementation <ILocation, Location>(); var company = container.GetInstance <ICompany>(); Assert.NotNull(company); }
public void RegisterMultipleAndGetInstances() { var container = new ContainerAdamIoC(); container.RegisterImplementation <IHuman, Man>(); container.RegisterImplementation <IVehicle, Car>(); var vehicle = container.GetInstance <IVehicle>(); var human = container.GetInstance <IHuman>(); Assert.NotNull(vehicle); Assert.NotNull(human); }
public void GetInstanceOfClassWithConstructoThatContainsParametersAndOneOfItsConstructorParametersAlsoHasAConstructorParameter() { var container = new ContainerAdamIoC(); container.RegisterImplementation <IContactInformation, CompanyContactPerson>(); container.RegisterImplementation <IHuman, ContactPerson>(); container.RegisterImplementation <ILocation, Location>(); container.RegisterImplementation <IName, ContactName>(); var contactInformation = container.GetInstance <IContactInformation>(); Assert.NotNull(contactInformation); }
public void TryToGetInstanceOfClassWithConstructorWhereNotAllParametersAreRegistered() { Assert.Throws <NotRegisteredException>(() => { var container = new ContainerAdamIoC(); container.RegisterImplementation <ICompany, Company>(); container.RegisterImplementation <IContactInformation, ContactInformation>(); var company = container.GetInstance <ICompany>(); Assert.NotNull(company); }); }
public void ResolveVehicle() { var container = new ContainerAdamIoC(); container.RegisterImplementation <IVehicle, Car>(); var vehicle = container.GetInstance <IVehicle>(); Assert.NotNull(vehicle); }
public void ShowThatVehicleInstancesAreNotTheSame() { var container = new ContainerAdamIoC(); container.RegisterImplementation <IVehicle, Car>(); var vehicle1 = container.GetInstance <IVehicle>(); var vehicle2 = container.GetInstance <IVehicle>(); Assert.NotNull(vehicle1); Assert.NotNull(vehicle2); Assert.NotEqual(vehicle1, vehicle2); }
public void ShowThatHumanInstancesAreTheSame() { var container = new ContainerAdamIoC(); container.RegisterImplementation <IHuman, Man>(LifecycleType.Singleton); var human1 = container.GetInstance <IHuman>(); var human2 = container.GetInstance <IHuman>(); Assert.NotNull(human1); Assert.NotNull(human2); Assert.Equal(human1, human2); }