Skip to content

Commit

Permalink
ShouldRegisterServiceDescriptorWithSpalId -> FAIL
Browse files Browse the repository at this point in the history
  • Loading branch information
LBoullosa committed Jun 3, 2024
1 parent e71db04 commit 1ace63b
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,58 @@ private void ShouldRegisterServiceDescriptor()

this.dependencyInjectionBroker.VerifyNoOtherCalls();
}

[Fact]
private void ShouldRegisterServiceDescriptorWithSpalId()
{
// given
dynamic randomProperties = CreateRandomProperties();
dynamic inputProperties = randomProperties;

ServiceDescriptor randomServiceDescriptor = randomProperties.ServiceDescriptorWithSpalId;
ServiceDescriptor inputServiceDescriptor = randomServiceDescriptor;
ServiceDescriptor expectedServiceDescriptor = inputServiceDescriptor;

IServiceCollection randomServiceCollection = randomProperties.ServiceCollection;
IServiceCollection expectedServiceCollection = randomServiceCollection;
IServiceCollection returnedServiceCollection = randomServiceCollection;

expectedServiceCollection.Add(inputServiceDescriptor);

this.dependencyInjectionBroker
.Setup(broker =>
broker.RegisterServiceDescriptor(
It.Is<ServiceDescriptor>(actualServiceDescriptor =>
SameServiceDescriptorAs(
actualServiceDescriptor,
expectedServiceDescriptor)
.Compile()
.Invoke(actualServiceDescriptor))))
.Returns(returnedServiceCollection);

// when
IServiceCollection actualServiceCollection =
this.serviceCollectionService.RegisterServiceDescriptor(
inputProperties.SpalInterfaceType,
inputProperties.SpalId,
inputProperties.ImplementationType,
inputProperties.ServiceLifeTime);

//then
actualServiceCollection.Should().BeSameAs(expectedServiceCollection);

this.dependencyInjectionBroker.Verify(
broker =>
broker.RegisterServiceDescriptor(
It.Is<ServiceDescriptor>(actualServiceDescriptor =>
SameServiceDescriptorAs(
actualServiceDescriptor,
expectedServiceDescriptor)
.Compile()
.Invoke(actualServiceDescriptor))),
Times.Once);

this.dependencyInjectionBroker.VerifyNoOtherCalls();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@ IServiceCollection RegisterServiceDescriptor(
Type spalInterfaceType,
Type implementationType,
ServiceLifetime serviceLifetime);

IServiceCollection RegisterServiceDescriptor(
Type spalInterfaceType,
string spalId,
Type implementationType,
ServiceLifetime serviceLifetime);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,14 @@ public IServiceCollection RegisterServiceDescriptor(

return dependencyInjectionBroker.RegisterServiceDescriptor(serviceDescriptor);
}

public IServiceCollection RegisterServiceDescriptor(
Type spalInterfaceType,
string spalId,
Type implementationType,
ServiceLifetime serviceLifetime)
{
throw new NotImplementedException();
}
}
}

0 comments on commit 1ace63b

Please sign in to comment.