Ejemplo n.º 1
0
        public void Setup()
        {
            CardRepo =
                new CardRepoMock
            {
                MockData =
                    new CreditCardInterestRates
                {
                    [CreditCardType.Visa]       = 0.1M,
                    [CreditCardType.MasterCard] = 0.05M,
                    [CreditCardType.Discover]   = 0.01M,
                }
            };

            CardRepo_Incomplete =
                new CardRepoMock
            {
                MockData =
                    new CreditCardInterestRates
                {
                    [CreditCardType.Visa] = 0.1M,
                    //[CreditCardType.MasterCard] = 0.05M,
                    [CreditCardType.Discover] = 0.01M,
                }
            };
        }
Ejemplo n.º 2
0
        public async Task Test_DeleteCard_ReturnsOk()
        {
            // Arrange
            var walletId = 1;

            CardRepoMock.Setup(r => r.DeleteAsync(walletId)).ReturnsAsync(0);

            // Act
            var response = await Client.DeleteAsync($"/api/cards/Delete/{walletId}");

            // Assert
            response.EnsureSuccessStatusCode();
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            CardRepoMock.Verify(r => r.DeleteAsync(walletId), Times.Once);
        }
Ejemplo n.º 3
0
        public async Task Test_AddCard_ReturnsOk()
        {
            // Arrange
            var newCard = new CardDTO {
                WalletId = 1, Description = "for shopping"
            };

            CardRepoMock.Setup(r => r.CreateAsync(It.IsAny <Card>())).ReturnsAsync(new Card());
            var newCardJson = JsonConvert.SerializeObject(newCard);
            var content     = new StringContent(newCardJson, Encoding.UTF8, "application/json");

            // Act
            var response = await Client.PostAsync("/api/cards/Create", content);

            // Assert
            response.EnsureSuccessStatusCode();
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            CardRepoMock.Verify(r => r.CreateAsync(It.IsAny <Card>()), Times.Once);
        }
Ejemplo n.º 4
0
        public void Setup()
        {
            var(people, _) = TestDataFactory.GetData(TestCaseId);

            People = people;

            var cardRepo =
                new CardRepoMock
            {
                MockData =
                    new CreditCardInterestRates
                {
                    [CreditCardType.Visa]       = 0.1M,
                    [CreditCardType.MasterCard] = 0.05M,
                    [CreditCardType.Discover]   = 0.01M,
                }
            };

            SimpleInterestCalculator = new SimpleInterestCalculator(cardRepo);
        }
Ejemplo n.º 5
0
        public async Task Test_DetailsCard_ReturnsOk()
        {
            // Arrange
            var walletId = 1;

            CardRepoMock.Setup(r => r.GetAsync(walletId)).ReturnsAsync(new Card {
                WalletId = walletId, Description = "for shopping", Number = "3566002020360505"
            });

            // Act
            var response = await Client.GetAsync($"/api/cards/Details/{walletId}");

            // Assert
            response.EnsureSuccessStatusCode();
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            var content = await response.Content.ReadAsStringAsync();

            var card = JsonConvert.DeserializeObject <CardDTO>(content);

            Assert.AreEqual(walletId, card.WalletId);
        }