Ejemplo n.º 1
0
        public void CreateWhithTheSameUserRequestShouldNotCreateNewRequest()
        {
            var options = new DbContextOptionsBuilder <XeonDbContext>()
                          .UseInMemoryDatabase(databaseName: "CreateTheSame_PartnerRequest_Database")
                          .Options;

            var dbContext = new XeonDbContext(options);

            var username = "******";
            var user     = new XeonUser {
                UserName = username
            };

            var userService = new Mock <IUsersService>();

            userService.Setup(r => r.GetUserByUsername(username))
            .Returns(user);

            var partnerRequestService = new PartnerRequestsService(userService.Object, dbContext);

            partnerRequestService.Create(username);
            partnerRequestService.Create(username);

            var partnerRequests = dbContext.PartnerRequests.ToList();

            Assert.Single(partnerRequests);
        }
Ejemplo n.º 2
0
        public void RemoveShouldRemovePartnerRequest()
        {
            var options = new DbContextOptionsBuilder <XeonDbContext>()
                          .UseInMemoryDatabase(databaseName: "Remove_PartnerRequest_Database")
                          .Options;

            var dbContext = new XeonDbContext(options);

            var username = "******";
            var user     = new XeonUser {
                UserName = username
            };

            var userService = new Mock <IUsersService>();

            userService.Setup(r => r.GetUserByUsername(username))
            .Returns(user);

            var partnerRequestService = new PartnerRequestsService(userService.Object, dbContext);

            partnerRequestService.Create(username);

            var partnerRequest = dbContext.PartnerRequests.FirstOrDefault(x => x.XeonUser.UserName == username);

            partnerRequestService.Remove(partnerRequest.Id);

            var partnerRequests = dbContext.PartnerRequests.ToList();

            Assert.Empty(partnerRequests);
        }