예제 #1
0
        public async Task UnblockUserByIdAsync_WithValidDAta_ShouldReturnTrue()
        {
            //Arrange
            var moqHttpContext = new Mock <IHttpContextAccessor>();
            var userStore      = new Mock <IUserStore <SellMeUser> >();
            var userManager    = new Mock <UserManager <SellMeUser> >(userStore.Object, null, null, null, null, null, null, null, null);
            var context        = InitializeContext.CreateContextForInMemory();

            this.usersService = new UsersService(context, moqHttpContext.Object, userManager.Object);

            var testingUser = new SellMeUser
            {
                Id             = "UserId",
                UserName       = "******",
                IsDeleted      = true,
                EmailConfirmed = true,
                CreatedOn      = DateTime.UtcNow.AddDays(-25),
                Ads            = new List <Ad> {
                    new Ad(), new Ad()
                }
            };

            await context.SellMeUsers.AddAsync(testingUser);

            await context.SaveChangesAsync();

            //Act
            var actual = await this.usersService.UnblockUserByIdAsync("UserId");

            //Assert
            Assert.True(actual);
            Assert.False(testingUser.IsDeleted);
        }
예제 #2
0
        public async Task GetMessageDetailsViewModelsAsync_WithCurrentUserNotParticipantInConversation_ShouldThrowAnInvalidOperationException()
        {
            //Arrange
            var expectedErrorMessage = "You are not participant in this conversation!";

            var moqAdsService   = new Mock <IAdsService>();
            var moqUsersService = new Mock <IUsersService>();

            moqUsersService.Setup(x => x.GetCurrentUserId())
            .Returns("FakeUserId");
            var moqIMapper = new Mock <IMapper>();
            var context    = InitializeContext.CreateContextForInMemory();

            var testingAd = CreateTestingAd();
            await context.AddAsync(testingAd);

            await context.SaveChangesAsync();

            messagesService = new MessagesService(context, moqAdsService.Object, moqUsersService.Object, moqIMapper.Object);

            //Act and assert
            var ex = await Assert.ThrowsAsync <InvalidOperationException>(() =>
                                                                          messagesService.GetMessageDetailsViewModelsAsync(1, "SenderId", "RecipientId"));

            Assert.Equal(expectedErrorMessage, ex.Message);
        }
예제 #3
0
        public async Task GetUserByIdAsync_WithValidDAta_ShouldReturnCorrectUser()
        {
            //Arrange
            var expectedUserId   = "UserId";
            var expectedUsername = "******";

            var moqHttpContext = new Mock <IHttpContextAccessor>();
            var userStore      = new Mock <IUserStore <SellMeUser> >();
            var userManager    = new Mock <UserManager <SellMeUser> >(userStore.Object, null, null, null, null, null, null, null, null);

            userManager.Setup(x => x.FindByIdAsync("UserId"))
            .ReturnsAsync(new SellMeUser {
                Id = "UserId", UserName = "******"
            });

            var context = InitializeContext.CreateContextForInMemory();

            this.usersService = new UsersService(context, moqHttpContext.Object, userManager.Object);

            var testingUser = new SellMeUser {
                Id = "UserId", UserName = "******"
            };

            await context.SellMeUsers.AddAsync(testingUser);

            await context.SaveChangesAsync();

            //Act
            var actual = await this.usersService.GetUserByIdAsync("UserId");

            //Assert
            Assert.Equal(expectedUserId, actual.Id);
            Assert.Equal(expectedUsername, actual.UserName);
        }
예제 #4
0
        public async Task GetAdministrationIndexStatisticViewModel_WithValidData_ShouldReturnCorrectResult()
        {
            //Assert
            var expectedActiveAdsCount = 10;
            var expectedAllUsersCount  = 5;

            var moqAdsService = new Mock <IAdsService>();

            moqAdsService.Setup(x => x.GetAllActiveAdsCountAsync())
            .ReturnsAsync(10);
            var moqUsersService = new Mock <IUsersService>();

            moqUsersService.Setup(x => x.GetCountOfAllUsersAsync())
            .ReturnsAsync(5);
            var moqPromotionsService = new Mock <IPromotionsService>();

            var context = InitializeContext.CreateContextForInMemory();

            statisticsService = new StatisticsService(context, moqAdsService.Object, moqUsersService.Object, moqPromotionsService.Object);

            //Act
            var actual = await statisticsService.GetAdministrationIndexStatisticViewModel();

            //Assert
            Assert.Equal(expectedActiveAdsCount, actual.AllAdsCount);
            Assert.Equal(expectedAllUsersCount, actual.AllUsersCount);
        }
예제 #5
0
        public async Task CreateInspect_WithValidInput_ShouldBeCorrect()
        {
            MapperInitializer.InitializeMapper();
            var context         = InitializeContext.CreateContextForInMemory();
            var repository      = new EfDeletableEntityRepository <Inspect>(context);
            var inspectsService = new InspectsService(repository);

            var userId           = "U1";
            var inspectTypeId    = "I1";
            var liftId           = "L1";
            var notes            = "test";
            var prescriptions    = "presTest";
            var supportCompanyId = "S1";

            await inspectsService.CreateAsync(userId, inspectTypeId, liftId, notes, prescriptions, supportCompanyId);

            var inspect = context.Inspects.FirstOrDefaultAsync().Result;

            Assert.Equal(userId, inspect.ApplicationUserId);
            Assert.Equal(inspectTypeId, inspect.InspectTypeId);
            Assert.Equal(liftId, inspect.LiftId);
            Assert.Equal(notes, inspect.Notes);
            Assert.Equal(prescriptions, inspect.Prescriptions);
            Assert.Equal(supportCompanyId, inspect.SupportCompanyId);
        }
예제 #6
0
        public async Task GetAddressByIdAsync_WithValidId_ShouldReturnCorrectAddress()
        {
            //Arrange
            var context = InitializeContext.CreateContextForInMemory();

            addressesService = new AddressesService(context);

            var addressId = 1;

            var testAddress = new Address
            {
                Id           = 1,
                City         = "Sofia",
                Country      = "Bulgaria",
                CreatedOn    = DateTime.UtcNow,
                EmailAddress = "*****@*****.**",
                District     = "Student City",
                ZipCode      = 1000,
                PhoneNumber  = "08552332",
                Street       = "Ivan Vazov"
            };

            await context.Addresses.AddAsync(testAddress);

            await context.SaveChangesAsync();

            //Act
            var result = await addressesService.GetAddressByIdAsync(addressId);

            //Assert
            Assert.Equal(result, testAddress);
        }
예제 #7
0
        public async Task GetAddressByIdAsync_WithInvalidId_ShouldThrowArgumentException(int addressId)
        {
            //Arrange
            var context = InitializeContext.CreateContextForInMemory();

            addressesService = new AddressesService(context);
            var testAddress = new Address
            {
                Id           = 1,
                City         = "Sofia",
                Country      = "Bulgaria",
                CreatedOn    = DateTime.UtcNow,
                EmailAddress = "*****@*****.**",
                District     = "Student City",
                ZipCode      = 1000,
                PhoneNumber  = "08552332",
                Street       = "Ivan Vazov"
            };

            await context.Addresses.AddAsync(testAddress);

            await context.SaveChangesAsync();

            var expectErrorMessage = "Address with the given ID doesn't exist!";

            //Act

            var ex = await Assert.ThrowsAsync <ArgumentException>(() => addressesService.GetAddressByIdAsync(addressId));

            Assert.Equal(expectErrorMessage, ex.Message);
        }
예제 #8
0
        public async Task GetTheCountOfPromotionsForTheLastTenDaysAsync_WithValidData_ShouldReturnCorrectResult()
        {
            //Arrange
            var expected = new List <int> {
                1, 0, 1, 0, 2, 0, 0, 0, 1, 1
            };

            var moqAdsService = new Mock <IAdsService>();
            var context       = InitializeContext.CreateContextForInMemory();

            promotionsService = new PromotionsService(context, moqAdsService.Object);

            var testingPromotions = new List <PromotionOrder>
            {
                new PromotionOrder {
                    Id = 1, CreatedOn = DateTime.UtcNow.AddDays(-5)
                },
                new PromotionOrder {
                    Id = 2, CreatedOn = DateTime.UtcNow.AddDays(-5)
                },
                new PromotionOrder {
                    Id = 3, CreatedOn = DateTime.UtcNow.AddDays(-7)
                },
                new PromotionOrder {
                    Id = 4, CreatedOn = DateTime.UtcNow.AddDays(-9)
                },
                new PromotionOrder {
                    Id = 5, CreatedOn = DateTime.UtcNow.AddDays(-1)
                },
                new PromotionOrder {
                    Id = 6, CreatedOn = DateTime.UtcNow.AddDays(-10)
                },
                new PromotionOrder {
                    Id = 7, CreatedOn = DateTime.UtcNow.AddDays(-30)
                },
                new PromotionOrder {
                    Id = 8, CreatedOn = DateTime.UtcNow
                }
            };

            await context.PromotionOrders.AddRangeAsync(testingPromotions);

            await context.SaveChangesAsync();

            //Act
            var actual = await promotionsService.GetTheCountOfPromotionsForTheLastTenDaysAsync();

            //Assert
            Assert.Equal(expected[0], actual[0]);
            Assert.Equal(expected[1], actual[1]);
            Assert.Equal(expected[2], actual[2]);
            Assert.Equal(expected[3], actual[3]);
            Assert.Equal(expected[4], actual[4]);
            Assert.Equal(expected[5], actual[5]);
            Assert.Equal(expected[6], actual[6]);
            Assert.Equal(expected[7], actual[7]);
            Assert.Equal(expected[8], actual[8]);
            Assert.Equal(expected[9], actual[9]);
        }
예제 #9
0
        public async Task GetUnreadMessagesCountAsync_WithValidData_ShouldReturnCorrectResult()
        {
            //Arrange
            var expected = 2;

            var moqAdsService   = new Mock <IAdsService>();
            var moqUsersService = new Mock <IUsersService>();
            var moqIMapper      = new Mock <IMapper>();
            var context         = InitializeContext.CreateContextForInMemory();

            messagesService = new MessagesService(context, moqAdsService.Object, moqUsersService.Object, moqIMapper.Object);

            var messages = new List <Message>
            {
                new Message
                {
                    AdId        = 1,
                    SenderId    = "SenderId",
                    RecipientId = "RecipientId",
                    Content     = "Content1",
                    IsRead      = false
                },
                new Message
                {
                    AdId        = 1,
                    SenderId    = "SenderId",
                    RecipientId = "RecipientId",
                    Content     = "Content2",
                    IsRead      = false
                },
                new Message
                {
                    AdId        = 1,
                    SenderId    = "SenderId",
                    RecipientId = "FakeRecipientId",
                    Content     = "Content3",
                    IsRead      = false
                },
                new Message
                {
                    AdId        = 1,
                    SenderId    = "SenderId",
                    RecipientId = "RecipientId",
                    Content     = "Content3",
                    IsRead      = true
                }
            };

            await context.Messages.AddRangeAsync(messages);

            await context.SaveChangesAsync();

            //Act
            var actual = await messagesService.GetUnreadMessagesCountAsync("RecipientId");

            //Assert
            Assert.Equal(expected, actual);
        }
        private static SupportCompaniesService InitializeCategoriesService()
        {
            MapperInitializer.InitializeMapper();
            var context    = InitializeContext.CreateContextForInMemory();
            var repository = new EfDeletableEntityRepository <SupportCompany>(context);
            var service    = new SupportCompaniesService(repository);

            return(service);
        }
        private static InspectTypesService InitializeCategoriesService()
        {
            MapperInitializer.InitializeMapper();
            var context    = InitializeContext.CreateContextForInMemory();
            var repository = new EfDeletableEntityRepository <InspectType>(context);
            var service    = new InspectTypesService(repository);

            return(service);
        }
예제 #12
0
        public async Task AddToFavoritesAsync_WithAdAlreadyInFavorites_ShouldThrowAnInvalidOperationException()
        {
            //Arrange
            var expectedErrorMessage = "The given ad is already added to favorites!";
            var context = InitializeContext.CreateContextForInMemory();

            var moqUserService = new Mock <IUsersService>();

            moqUserService.Setup(x => x.GetCurrentUserAsync())
            .ReturnsAsync(new SellMeUser
            {
                Id       = Guid.NewGuid().ToString(),
                UserName = "******",
                SellMeUserFavoriteProducts = new List <SellMeUserFavoriteProduct>
                {
                    new SellMeUserFavoriteProduct
                    {
                        AdId = 1
                    }
                }
            });

            favoritesService = new FavoritesService(context, moqUserService.Object);
            var testingAd = new Ad
            {
                Id                = 1,
                Title             = "Iphone 6s",
                Description       = "PerfectCondition",
                ActiveFrom        = DateTime.UtcNow,
                ActiveTo          = DateTime.UtcNow.AddDays(30),
                AvailabilityCount = 1,
                Price             = 120,
                Condition         = new Condition {
                    Name = "Brand New"
                },
                Address = new Address
                {
                    Country      = "Bulgaria",
                    City         = "Sofia",
                    Street       = "Ivan Vazov",
                    District     = "Student city",
                    ZipCode      = 1000,
                    PhoneNumber  = "0895335532",
                    EmailAddress = "*****@*****.**"
                }
            };

            await context.Ads.AddAsync(testingAd);

            await context.SaveChangesAsync();

            //Act and assert
            var ex = await Assert.ThrowsAsync <InvalidOperationException>(() => favoritesService.AddToFavoritesAsync(1));

            Assert.Equal(expectedErrorMessage, ex.Message);
        }
        private LiftsService InitializeCategoriesService()
        {
            MapperInitializer.InitializeMapper();
            var context = InitializeContext.CreateContextForInMemory();

            this.repository = new EfDeletableEntityRepository <Lift>(context);
            var service = new LiftsService(this.repository);

            return(service);
        }
        public async Task CreateCity_WithNotValidInput_ShouldBeReturnFalse(string input)
        {
            this.context       = InitializeContext.CreateContextForInMemory();
            this.citiesService = InitializeCategoriesService(this.context);

            string cityName = input;

            var isCreate = await this.citiesService.CreateAsync(cityName);

            Assert.False(isCreate);
        }
        public async Task CreateCity_WithValidInput_ShouldBeReturnCorrectBool()
        {
            this.context       = InitializeContext.CreateContextForInMemory();
            this.citiesService = InitializeCategoriesService(this.context);

            string cityName = "Бургас";

            var isCreate = await this.citiesService.CreateAsync(cityName);

            Assert.True(isCreate);
        }
예제 #16
0
        public async Task GetRatingByUserAsync_WithValidData_ShouldReturnCorrectResult()
        {
            //Arrange
            var expected = 2;

            var moqHttpContext = new Mock <IHttpContextAccessor>();
            var userStore      = new Mock <IUserStore <SellMeUser> >();
            var userManager    = new Mock <UserManager <SellMeUser> >(userStore.Object, null, null, null, null, null, null, null, null);

            userManager.Setup(x => x.FindByIdAsync("UserId"))
            .ReturnsAsync(new SellMeUser
            {
                Id           = "UserId",
                UserName     = "******",
                OwnedReviews = new List <Review>
                {
                    new Review {
                        Comment = "Comment1", Rating = 5
                    },
                    new Review {
                        Comment = "Comment2", Rating = 2
                    },
                    new Review {
                        Comment = "Comment3", Rating = 1
                    },
                    new Review {
                        Comment = "Comment4", Rating = 1
                    },
                    new Review {
                        Comment = "Comment5", Rating = 1
                    },
                }
            });
            var context = InitializeContext.CreateContextForInMemory();

            this.usersService = new UsersService(context, moqHttpContext.Object, userManager.Object);

            var testingUser = new SellMeUser {
                Id = "UserId", UserName = "******"
            };

            await context.SellMeUsers.AddAsync(testingUser);

            await context.SaveChangesAsync();

            //Act
            var actual = await this.usersService.GetRatingByUserAsync("UserId");

            //Assert
            Assert.Equal(expected, actual);
        }
        public async Task GetAllCities_WithValidInput_ShouldBeReturnCorrectAllCitiesForViewModel()
        {
            this.context       = InitializeContext.CreateContextForInMemory();
            this.citiesService = InitializeCategoriesService(this.context);

            string cityName = "София";

            await this.citiesService.CreateAsync(cityName);

            var cities = await this.citiesService.GetAllCityForViewModel();

            Assert.Equal(1, cities.Count);
            Assert.Equal(cityName, cities.FirstOrDefault().Name);
        }
예제 #18
0
        public async Task CreateMessageAsync_WithValidData_ShouldCreateAMessage()
        {
            //Arrange
            var expected = new MessageDetailsViewModel
            {
                AdTitle = "Iphone 6s",
                Content = "Content for the message",
                Sender  = "Ivan",
                SentOn  = "31/01/2019"
            };

            var moqAdsService   = new Mock <IAdsService>();
            var moqUsersService = new Mock <IUsersService>();

            moqUsersService.Setup(x => x.GetUserByIdAsync("SenderId"))
            .ReturnsAsync(new SellMeUser
            {
                Id       = "SenderId",
                UserName = "******"
            });

            var moqMapper = new Mock <IMapper>();

            moqMapper.Setup(x => x.Map <MessageDetailsViewModel>(It.IsAny <Message>()))
            .Returns(new MessageDetailsViewModel
            {
                AdTitle = "Iphone 6s",
                Content = "Content for the message",
                Sender  = "Ivan",
                SentOn  = "31/01/2019"
            });

            var context = InitializeContext.CreateContextForInMemory();

            messagesService = new MessagesService(context, moqAdsService.Object, moqUsersService.Object, moqMapper.Object);

            var testingAd = CreateTestingAd();
            await context.Ads.AddAsync(testingAd);

            await context.SaveChangesAsync();

            //Act and assert
            var actual = await messagesService.CreateMessageAsync("SenderId", "RecipientId",
                                                                  1, "Content for the message");

            Assert.Equal(expected.AdTitle, actual.AdTitle);
            Assert.Equal(expected.Content, actual.Content);
            Assert.Equal(expected.Sender, actual.Sender);
            Assert.Equal(expected.SentOn, actual.SentOn);
        }
예제 #19
0
        public void CheckOwnerIdAndSellerId_WithOwnerDifferentFromCreator_ShouldReturnFalse()
        {
            //Arrange
            var moqUsersService = new Mock <IUsersService>();
            var context         = InitializeContext.CreateContextForInMemory();

            reviewsService = new ReviewsService(context, moqUsersService.Object);

            //Act
            var actual = reviewsService.CheckOwnerIdAndSellerId("CreatorId", "AnotherUserId");

            //Assert
            Assert.False(actual);
        }
예제 #20
0
        public async Task CreateUpdateAdAsync_WithInvalidAdId_ShouldThrowAndInvalidArgumentException()
        {
            //Arrange
            var expectedErrorMessage = "Ad with the given id doesn't exist!";

            var context = InitializeContext.CreateContextForInMemory();

            updatesService = new UpdatesService(context);

            //Act and assert
            var ex = await Assert.ThrowsAsync <ArgumentException>(() => updatesService.CreateUpdateAdAsync(1));

            Assert.Equal(expectedErrorMessage, ex.Message);
        }
예제 #21
0
        public void GetAllCountries_ShouldReturnTheCorrectCount()
        {
            //Arrange
            var context = InitializeContext.CreateContextForInMemory();

            addressesService = new AddressesService(context);
            var expectedCount = 142;

            //Act
            var countriesCount = addressesService.GetAllCountries().Count;

            //Assert
            Assert.Equal(expectedCount, countriesCount);
        }
예제 #22
0
        public void GetConditionViewModels_WithoutData_ShouldReturnAnEmptyCollection()
        {
            //Arrange
            var expected = 0;

            var context = InitializeContext.CreateContextForInMemory();

            conditionsService = InitializeConditionsService(context);

            var actual = conditionsService.GetConditionViewModels();

            //Act and assert
            Assert.Equal(expected, actual.Count);
        }
예제 #23
0
        public async Task GetAllCategoryViewModelsAsync_WithoutData_ShouldReturnAnEmptyCollection()
        {
            //Arrange
            var expected = 0;

            var context = InitializeContext.CreateContextForInMemory();

            categoriesService = InitializeCategoriesService(context);

            var actual = await categoriesService.GetAllCategoryViewModelsAsync();

            //Act and assert
            Assert.Equal(expected, actual.Count);
        }
예제 #24
0
        public async Task AddToFavoritesAsync_WithValidData_ShouldReturnTrue()
        {
            //Arrange
            var context = InitializeContext.CreateContextForInMemory();

            var moqUserService = new Mock <IUsersService>();

            moqUserService.Setup(x => x.GetCurrentUserAsync())
            .ReturnsAsync(new SellMeUser
            {
                Id       = Guid.NewGuid().ToString(),
                UserName = "******"
            });

            favoritesService = new FavoritesService(context, moqUserService.Object);
            var testingAd = new Ad
            {
                Id                = 1,
                Title             = "Iphone 6s",
                Description       = "PerfectCondition",
                ActiveFrom        = DateTime.UtcNow,
                ActiveTo          = DateTime.UtcNow.AddDays(30),
                AvailabilityCount = 1,
                Price             = 120,
                Condition         = new Condition {
                    Name = "Brand New"
                },
                Address = new Address
                {
                    Country      = "Bulgaria",
                    City         = "Sofia",
                    Street       = "Ivan Vazov",
                    District     = "Student city",
                    ZipCode      = 1000,
                    PhoneNumber  = "0895335532",
                    EmailAddress = "*****@*****.**"
                }
            };

            await context.Ads.AddAsync(testingAd);

            await context.SaveChangesAsync();

            //Act
            var actual = await favoritesService.AddToFavoritesAsync(1);

            //Assert
            Assert.True(actual);
        }
예제 #25
0
        public async Task GetSubcategoriesByCategoryIdAsync_WithInvalidCategoryId_ShouldThrowAndInvalidArgumentException()
        {
            //Arrange
            var expectedErrorMessage = "Category with the given id doesn't exist!";

            var context = InitializeContext.CreateContextForInMemory();

            subcategoriesService = new SubCategoriesService(context);

            //Act and assert
            var ex = await Assert.ThrowsAsync <ArgumentException>(() =>
                                                                  subcategoriesService.GetSubcategoriesByCategoryIdAsync(1));

            Assert.Equal(expectedErrorMessage, ex.Message);
        }
예제 #26
0
        public async Task AddToFavoritesAsync_WithCurrentUserEqualsToNull_ShouldThrowAndInvalidOperationException()
        {
            //Arrange
            var expectedErrorMessage = "Current user can't be null";
            var context = InitializeContext.CreateContextForInMemory();

            var moqUserService = new Mock <IUsersService>();

            favoritesService = new FavoritesService(context, moqUserService.Object);

            //Act and assert
            var ex = await Assert.ThrowsAsync <InvalidOperationException>(() => favoritesService.AddToFavoritesAsync(1));

            Assert.Equal(expectedErrorMessage, ex.Message);
        }
예제 #27
0
        public async Task GetInspect_WithValidInput_ShouldBeREturnCorrectInspectWithViewModel()
        {
            MapperInitializer.InitializeMapper();
            var context         = InitializeContext.CreateContextForInMemory();
            var repository      = new EfDeletableEntityRepository <Inspect>(context);
            var inspectsService = new InspectsService(repository);

            var ins = new Inspect
            {
                Id = "1",
                ApplicationUserId = "U1",
                InspectTypeId     = "I1",
                LiftId            = "L1",
                Notes             = "test",
                Prescriptions     = "presTest",
                SupportCompanyId  = "S1",
            };

            await context.Inspects.AddAsync(ins);

            await context.SaveChangesAsync();

            // var repositoryTest = new EfDeletableEntityRepository<Inspect>(context);

            // var userId = "U1";
            // var inspectTypeId = "I1";
            // var liftId = "L1";
            // var notes = "test";
            // var prescriptions = "presTest";
            // var supportCompanyId = "S1";
            // await inspectsServiceTest.CreateAsync(userId, inspectTypeId, liftId, notes, prescriptions, supportCompanyId);
            var test = await context.Inspects.FirstOrDefaultAsync();

            // Assert.Equal(inspectTypeId, test.InspectTypeId);
            // var inspectViewModel = inspectsServiceTest.GetCurrentInspect(test.Id);
            Assert.Equal(1, context.Inspects.Count());
            Assert.NotNull(inspectsService);
            Assert.NotNull(test);

            // Assert.Null(inspectViewModel);
            // Assert.Equal(inspectTypeId, inspect.InspectTypeId);
            // Assert.Equal(test, inspectViewModel);
            // Assert.Equal(inspectTypeId, inspectViewModel.InspectTypeId);
            // Assert.Equal(liftId, inspectViewModel.LiftId);
            // Assert.Equal(notes, inspectViewModel.Notes);
            // Assert.Equal(prescriptions, inspectViewModel.Prescriptions);
            // Assert.Equal(supportCompanyId, inspectViewModel.SupportCompanyId);
        }
예제 #28
0
        public async Task GetTheCountOfPromotionsForTheLastTenDaysAsync_WithValidData_ShouldReturnCorrectCollectionLength()
        {
            //Arrange
            var expectedLength = 10;

            var moqAdsService = new Mock <IAdsService>();
            var context       = InitializeContext.CreateContextForInMemory();

            promotionsService = new PromotionsService(context, moqAdsService.Object);

            //Act
            var actual = await promotionsService.GetTheCountOfPromotionsForTheLastTenDaysAsync();

            //Assert
            Assert.Equal(expectedLength, actual.Count);
        }
예제 #29
0
        public async Task CreateReview_WithNullOrEmptyArguments_ShouldThrowAnArgumentException(string ownerId, string creatorId, string content)
        {
            //Arrange
            var expectedErrorMessage = "Some of the arguments are null or empty!";
            var moqUsersService      = new Mock <IUsersService>();
            var context = InitializeContext.CreateContextForInMemory();

            reviewsService = new ReviewsService(context, moqUsersService.Object);


            //Assert and act
            var ex = await Assert.ThrowsAsync <ArgumentException>(() =>
                                                                  reviewsService.CreateReview(ownerId, creatorId, content, 1));

            Assert.Equal(expectedErrorMessage, ex.Message);
        }
예제 #30
0
        public async Task CreateReview_WithValidData_ShouldCreateAReview()
        {
            //Arrange
            var expectedReviewsCount = 1;

            var moqUsersService = new Mock <IUsersService>();
            var context         = InitializeContext.CreateContextForInMemory();

            reviewsService = new ReviewsService(context, moqUsersService.Object);

            //Act
            await reviewsService.CreateReview("OwnerId", "CreatorId", "Content", 3);

            //Assert
            Assert.Equal(expectedReviewsCount, context.Reviews.Count());
        }