Exemplo n.º 1
0
        public void Should_ReturnSameObject_When_TheServiceIsAlreadyRegistered()
        {
            // Given
            var service = new FakeSampleService();

            SUT.InternalServiceCollection.AddSingleton <ISampleService>(service);

            // When
            var gettingService = SUT.GetOrAddInternalService <ISampleService>(() => new FakeSampleService());

            // Then
            service.Should().BeSameAs(gettingService);
        }
        public void SuccessTest()
        {
            // Given
            var fakeSampleService = new FakeSampleService();

            SUT.ReplaceService <ISampleService>(fakeSampleService);

            // When
            SUT.CreateClient();

            // Then
            SUT.VerifyRegistrationByCondition(descriptor => descriptor.ServiceType == typeof(ISampleService) &&
                                              descriptor.ImplementationInstance == fakeSampleService);
        }
Exemplo n.º 3
0
        public async Task Should_When_ImplementationObject()
        {
            var serviceObject = new FakeSampleService
            {
                Message = "Fake More!"
            };
            var httpClient = SUT
                             .ReplaceService <ISampleService>(serviceObject)
                             .CreateClient();

            var response = await httpClient.Resource("api/sample/data").GetAsync();

            var sample = await response.ShouldBeOk <SampleDataResponse>();

            sample.Data.Should().Be("Fake More!");
        }