Exemple #1
0
        public async Task ShouldGetEnglishFractions()
        {
            // Arrange
            var expectedDeclarations = new List <FractionCalculation>
            {
                new FractionCalculation()
            };
            var expected = new EnglishFractionDeclarations
            {
                Empref = "000/AA00000",
                FractionCalculations = expectedDeclarations
            };
            var mockHttp = new MockHttpMessageHandler();

            mockHttp.When($"http://localhost/apprenticeship-levy/epaye/{HttpUtility.UrlEncode(expected.Empref)}/fractions")
            .Respond("application/json", JsonConvert.SerializeObject(expected));

            var client = GetApprenticeshipLevyApiClient(mockHttp);

            // Act
            var declarations = await client.GetEmployerFractionCalculations(expected.Empref);

            // Assert
            mockHttp.VerifyNoOutstandingExpectation();
            Assert.AreEqual(expected.Empref, declarations.Empref);
            Assert.AreEqual(expected.FractionCalculations.Count, declarations.FractionCalculations.Count);
        }
Exemple #2
0
        public async Task ThenIShouldGetBackDeclarationsForAGivenEmpRef()
        {
            //Arrange

            var expectedApiUrl = $"apprenticeship-levy/epaye/{HttpUtility.UrlEncode(EmpRef)}/fractions";

            var englishFractions = new EnglishFractionDeclarations();

            _httpClientWrapper.Setup(x => x.Get <EnglishFractionDeclarations>(It.IsAny <string>(), expectedApiUrl))
            .ReturnsAsync(englishFractions);

            //Act
            var result = await _hmrcService.GetEnglishFractions(EmpRef);

            //Assert
            _httpClientWrapper.Verify(x => x.Get <EnglishFractionDeclarations>(ExpectedAuthToken, expectedApiUrl), Times.Once);
            Assert.AreEqual(englishFractions, result);
        }
        public async Task ThenIShouldGetBackDeclarationsForAGivenEmpRef()
        {
            //Arrange

            var englishFractions = new EnglishFractionDeclarations();

            _apprenticeshipLevyApiClient.Setup(x => x.GetEmployerFractionCalculations(It.IsAny <string>(),
                                                                                      It.IsAny <string>(), It.IsAny <DateTime?>(), It.IsAny <DateTime?>()))
            .ReturnsAsync(englishFractions);

            //Act
            var result = await _hmrcService.GetEnglishFractions(EmpRef);

            //Assert
            _apprenticeshipLevyApiClient.Verify(
                x => x.GetEmployerFractionCalculations(ExpectedAuthToken, It.IsAny <string>(), It.IsAny <DateTime?>(),
                                                       It.IsAny <DateTime?>()), Times.Once);
            Assert.AreEqual(englishFractions, result);
        }
Exemple #4
0
        public static EnglishFractionDeclarations Create(string empRef)
        {
            var declarations = new EnglishFractionDeclarations
            {
                Empref = empRef,
                FractionCalculations = new List <FractionCalculation>
                {
                    new FractionCalculation
                    {
                        CalculatedAt = "2017 06 01",
                        Fractions    = new List <Fraction>
                        {
                            new Fraction
                            {
                                Region = "England",
                                Value  = "0.67",
                            }
                        }
                    },
                    new FractionCalculation
                    {
                        CalculatedAt = "2017 10 01",
                        Fractions    = new List <Fraction>
                        {
                            new Fraction
                            {
                                Region = "England",
                                Value  = "0.97",
                            }
                        }
                    }
                }
            };

            return(declarations);
        }