Exemplo n.º 1
0
        public async Task AcceptOrderAsync_WithCorrectData_ShouldSuccessfullyUpdate()
        {
            var errorMessage = "BoostingService AcceptOrderAsync() method does not work properly.";

            // Arrange
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            var boostOrdersRepository = new EfRepository <BoostOrder>(context);

            var boostingService = new BoostingService(boostOrdersRepository);

            var user = new ApplicationUser
            {
                Id = Guid.NewGuid().ToString(),
            };

            var boostOrderModel = new PurchaseInputModel
            {
                CurrentRank = "Diamond 1",
                Ranks       = 1,
                Username    = "******",
                Password    = "******",
            };

            // Act
            await boostingService.AddAsync(boostOrderModel);

            await boostingService.AcceptOrderAsync(user, boostOrderModel.Username);

            var actualResult   = boostOrdersRepository.All().First();
            var expectedResult = user.Id;

            // Assert
            Assert.True(expectedResult == actualResult.BoosterId, errorMessage);
        }
Exemplo n.º 2
0
        public async Task GetAllBoostOrders_WithCorrectData_ShouldReturnCorrectResult()
        {
            var errorMessage = "BoostingService GetAllBoostOrders() method does not work properly.";

            // Arrange
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            var boostOrdersRepository = new EfRepository <BoostOrder>(context);

            var boostingService = new BoostingService(boostOrdersRepository);

            var boostOrderModel = new PurchaseInputModel
            {
                CurrentRank = "Diamond 1",
                Ranks       = 1,
                Username    = "******",
                Password    = "******",
            };

            // Act
            await boostingService.AddAsync(boostOrderModel);

            var actualResult   = boostingService.GetAllBoostOrders().First();
            var expectedResult = boostOrderModel;

            // Assert
            Assert.True(expectedResult.CurrentRank == actualResult.CurrentRank, errorMessage);
            Assert.True(expectedResult.Ranks == actualResult.Ranks, errorMessage);
            Assert.True(expectedResult.Username == actualResult.Username, errorMessage);
            Assert.True(expectedResult.Password == actualResult.Password, errorMessage);
        }