public void when_add_producers_for_different_apis_it_should_successfully_register_them() { var sut = new DefaultProducerRegistry(); var api1 = Mock.Of <IEgressApi>(); var producer1 = Mock.Of <IApiProducer>(); sut.Add(api1, producer1); var api2 = Mock.Of <IEgressApi>(); var producer2 = Mock.Of <IApiProducer>(); sut.Add(api2, producer2); sut.Get(api1).Should().Be(producer1, "this producer registered for this API"); sut.Get(api2).Should().Be(producer2, "this producer registered for this API"); }
public void when_get_producer_for_null_as_api_it_should_fail() { var registry = new DefaultProducerRegistry(); Action sut = () => registry.Get(api: null); sut.Should().ThrowExactly <ArgumentNullException>(); }
public void when_get_not_registered_producer_it_should_fail() { var registry = new DefaultProducerRegistry(); Action sut = () => registry.Get(Mock.Of <IEgressApi>()); sut.Should().ThrowExactly <ArgumentException>().Where(exception => exception.ParamName.Equals("api"), "API is required"); }
public void when_get_producer_for_unregistered_api_it_should_fail() { var registry = new DefaultProducerRegistry(); var apiMock = new Mock <IEgressApi>(); apiMock.SetupGet(api => api.Id).Returns("id-1"); Action sut = () => registry.Get(Mock.Of <IEgressApi>()); sut.Should().ThrowExactly <ArgumentException>() .Where(exception => exception.Message.Contains("There is no registered producers for API with ID"), "should fail"); }