public void Setup()
		{
            product = new Product
            {
                Reviews =
                    {
                        new Review(),
                        new Review()
                    }
            };

            productRepository = new FakeRepository<Product>(id =>
            {
                product.Id = id;
                return product;
            });

            reviewRepository = MockRepositoryBuilder.CreateReviewRepository();

            commentRepository = MockRepository.GenerateStub<IRepository<IComment>>();

            var comments = new List<IComment>
	        {
                new Comment{ Approved = true },
                new Comment{ Approved = false },
                new Review{ Approved = true },
                new Comment{ Approved = true }
	        }.AsQueryable();
            commentRepository.Stub(r => r.GetAll()).Return(comments);

            controller = new ReviewsController(reviewRepository, productRepository, commentRepository);
		}
Example #2
0
        public void Before_Each_Test()
        {
            console = MockRepository.GenerateMock<IConsoleFacade>();
            repository = MockRepository.GenerateMock<IRepository<GameObject>>();
            player = MockRepository.GenerateMock<IPlayer>();

            dbPlayer = new GameObject() { GameObjectId = 3, Location = dbHallway, Location_Id = 8, Description = "Just some dude." };
            player.Stub(qq => qq.Id).Return(3);
            dbHallway = new GameObject() { Name = "Hallway", Description = " It's a hallway", GameObjectId = 8 };
            dbBall = new GameObject() { Name = "Ball", Description = "A shiny rubber ball", Location = dbPlayer, Location_Id = 3 };
            dbRing = new GameObject() { Name = "Ring", Description = "A simple gold ring", Location = dbHallway, Location_Id = 8 };
            dbExit = new GameObject() {Name = "Exit", Description ="", Location= dbHallway, Location_Id = 8, GameObjectId = 16, Type = "Exit", Destination = 8 };

            dbPlayer.Inventory.Add(dbBall);
            dbHallway.Inventory.Add(dbPlayer);
            dbHallway.Inventory.Add(dbRing);
            dbHallway.Inventory.Add(dbExit);
            dbList = new List<GameObject>() { dbPlayer, dbBall, dbRing, dbExit, dbHallway };
            repository.Stub(qq => qq.AsQueryable()).Return(dbList.AsQueryable());

            exit = new ExitAlias() { AliasId = 2, ExitId = 16, Alais = "North" };
            exit2 = new ExitAlias() { AliasId = 2, ExitId = 16, Alais = "Hall" };
            dbExit.ExitAliases.Add(exit);
            dbExit.ExitAliases.Add(exit2);
            aliasList = new List<ExitAlias> { exit, exit2 };
        }
        public void SetUp()
        {
            postageRepository = MockRepository.GenerateMock<IRepository<Postage>>();

            postageService = new PostageService(postageRepository);

            var postages = PostageTests.CreatePostages();
            postageRepository.Stub(pr => pr.GetAll()).Return(postages);
        }
        public void Context()
        {
            _emailRepository = MockRepository.GenerateMock<IRepository<Email>>();
            _emailTemplateRepository = MockRepository.GenerateStub<IRepository<EmailTemplate>>();
            const int emailTemplateId = 23;
            _emailTemplateRepository.Stub(a => a.GetById(emailTemplateId)).Return(new EmailTemplate(123));

            var handler = new CreateEmailCommandHandler(_emailRepository, _emailTemplateRepository);
            handler.CommandExecuted += (sender, args) => _eventRaised = true;
            handler.Execute(new CreateEmailCommand { EmailTemplateId = emailTemplateId});
        }
 public void SetUp()
 {
     builder = new PizzaTypeEditorConvention();
     pizzaType = new PizzaType { Id = new Guid(), Name = "Test", Description = "Test description" };
     order = new PickupOrder { Id = new Guid(), PizzaType = pizzaType };
     services = MockRepository.GenerateStub<IServiceLocator>();
     repository = MockRepository.GenerateStub<IRepository>();
     stringifier = new Stringifier();
     repository.Stub(r => r.GetAll<PizzaType>()).Return(new List<PizzaType> { pizzaType });
     services.Stub(l => l.GetInstance<IRepository>()).Return(repository);
     services.Stub(l => l.GetInstance<Stringifier>()).Return(stringifier);
 }
        protected override void Before_each()
        {
            _aiList = new List<AssaultItem>
                          {
                              new AssaultItem {Description = "Stormtrooper"},
                              new AssaultItem {Description = "AT-ST"}
                          };

            _repo = Stub<IRepository<AssaultItem>>();
            _repo.Stub(x => x.GetAll()).Return(_aiList);

            _service = new InventoryService(_repo);
        }
        public void context()
        {
            MvcApplication.InitializeContainer(new TestContainer());

            var principal = MockRepository.GenerateStub<IPrincipal>();
            var visitor = MockRepository.GenerateStub<SiteVisitor>();
            visitor.Stub(x => x.FirstName).Return("Michael");

            userRepository = MockRepository.GenerateStub<IRepository<SiteVisitor>>();
            userRepository.Stub(x => x.Find(Arg<Func<SiteVisitor, bool>>.Is.Anything)).Return(new List<SiteVisitor>() { visitor });

            loginController = new LoginController(userRepository);
            loginController.Submit("[email protected]", System.Guid.NewGuid().ToString());
        }
Example #8
0
        public void GlobalArrange()
        {
            repoFactory = MockRepository.GenerateMock<IRepositoryFactory>();
            factory = MockRepository.GenerateMock<IRepositoryFactoryFactory>();
            console = MockRepository.GenerateMock<IConsoleFacade>();
            repo = MockRepository.GenerateMock<IRepository>();
            uow = MockRepository.GenerateMock<IUnitOfWork>();
            goQueries = MockRepository.GenerateMock<IGameObjectQueries>();
            //formatters = MockRepository.GenerateMock<IFormatter[]>();

            factory.Stub(m => m.Create()).Return(repoFactory);
            repoFactory.Stub(m => m.Create()).Return(repo);
            repo.Stub(m => m.UnitOfWork).Return(uow);

            //target = new LookCommand(console, factory, goQueries, formatters);
        }
	    public void SetUp()
	    {
            basketRepository = MockRepository.GenerateStub<IRepository<Basket>>();
            encryptionService = MockRepository.GenerateStub<IEncryptionService>();
	        postageService = MockRepository.GenerateStub<IPostageService>();
	        userService = MockRepository.GenerateStub<IUserService>();

            checkoutService = new CheckoutService(basketRepository, encryptionService, postageService, userService);

            checkoutViewData = GetCheckoutViewData();
            basket = CreateBasketWithId(7);
            basketRepository.Stub(r => r.GetById(7)).Return(basket);

            user = new User { Role = Role.Administrator };
	        userService.Stub(u => u.CurrentUser).Return(user);
	    }
        public void BeforeAll()
        {
            _repository = MockRepository.GenerateStub<IRepository>();
            _repository.Stub(r => r.Find<Campground>()).Return(
                Builder<Campground>
                .CreateListOfSize(10)
                .Build()
                .AsQueryable());
            var command = new CreateCampgroundCommand(_repository);

            _request = Builder<CreateCampgroundRequest>
                .CreateNew()
                .Do(r=>r.Location = new []{45.5m,23.45m})
                .Do(r=>r.Name = "Where I camp at")
                .Build();

            _response = command.Execute(_request);
        }
        public void BeforeAll()
        {
            var campsiteId = "the site number";
            _campsite = Builder<Campsite>.CreateNew().Do(c => c.Id = campsiteId).Build();

            _repository = MockRepository.GenerateStub<IRepository>();
            _repository.Stub(r => r.Get<Campsite>(campsiteId)).Return(_campsite);
           
            var command = new CreateCampsiteReviewCommand(_repository);

            _request = Builder<CreateCampsiteReviewRequest>
                .CreateNew()
                .Do(r=>r.CampsiteId = campsiteId)
                .Do(r=>r.Rating = 4)
                .Build();

            _response = command.Execute(_request);
        }
        public void DogsControllerTestsSetup()
        {
            _dogsRepository = MockRepository.GenerateMock<IRepository<Dog>>();
              _breedsRepository = MockRepository.GenerateMock<IRepository<Breed>>();
              _placesRepository = MockRepository.GenerateMock<IPlacesRepository>();
              _unitofWork = MockRepository.GenerateMock<IUnitOfWork>();
              _dogSearchhelper = MockRepository.GenerateMock<IDogSearchService>();
              _configuration = MockRepository.GenerateMock<IConfiguration>();

              _breedsRepository.Stub(x => x.GetById(Arg<int>.Is.Anything)).Return(
            new Breed {Name = "Beagel"});

              _configuration.Stub(x => x.GetNationwideSearchResultsDescriptionMessageForAllBreeds())
            .Return("Search results {0} to {1} out of {2} results for all breeds nationwide.");
              _configuration.Stub(x => x.GetNationwideSearchResultsDescriptionMessageForSpecificBreed())
            .Return("Showing results {0} to {1} out of {2} results for {3} nationwide");
              _configuration.Stub(x => x.GetLocalSearchResultsDescriptionMessageForAllBreeds())
            .Return("Search results {0} to {1} out of {2} results for all breeds in {3}");

              _dogsController = new DogsController(_dogsRepository, _breedsRepository, _unitofWork, _dogSearchhelper, _configuration, _placesRepository);

              StubDogsRepository();
        }
Example #13
0
        public void SetUp()
        {
            repository = MockRepository.GenerateMock<IRepository>();
            userTasks = MockRepository.GenerateMock<IUserTasks>();
            projectTaskType = new ProjectTaskType();
            user = new User();

            this.createWorkItemRequest = new CreateWorkItemRequest()
            {
                Name = "Bond",
                ProjectTaskTypeId = Guid.NewGuid()
            };
            repository.Stub(x => x.Get<ProjectTaskType>(createWorkItemRequest.ProjectTaskTypeId)).Return(projectTaskType);
            repository.Stub(x => x.Query<WorkItem>()).Return((new WorkItem[0]).AsQueryable());
            userTasks.Stub(x => x.GetCurrentUser()).Return(user);
        }
        public void SetUp()
        {
            _sessionPlayer = new Player();
            _databaseAccount = new Account {EmailAddress = "[email protected]"};
            _databasePlayer = new Player { Account = _databaseAccount };
            _sessionAccount = new Account();

            _httpSession = MockRepository.GenerateMock<IHttpSession>();
            _user = MockRepository.GenerateMock<IPrincipal>();
            _identity = MockRepository.GenerateMock<IIdentity>();
            _accountRepository = MockRepository.GenerateMock<IRepository<Account>>();
            _playerRepository = MockRepository.GenerateMock<IRepository<Player>>();

            _user.Stub(m => m.Identity).Return(_identity);
            _identity.Stub(m => m.Name).Return(_databaseAccount.EmailAddress);
            _accountRepository.Stub(m => m.Get).Return((new Collection<Account>{_databaseAccount}).AsQueryable());

            _userProvider = new TestUserProvider(_accountRepository, _playerRepository, _httpSession, _user);
        }
        protected override void Before_each()
        {
            _repo = Stub<IRepository<AssaultItem>>();
            _repo.Stub(x => x.GetById(2)).Return(new AssaultItem {Description = "AI2"});

            _service = new InventoryService(_repo);
        }
        public void Setup()
        {
            _category1 = new Category {CategoryID = 1};
            _category2 = new Category {CategoryID = 2};
            _post1 = new Post { PostID = 1, PostedAt = DateTime.Now.Subtract(TimeSpan.FromDays(50)), Categories = new Collection<Category>{_category1}};
            _post2 = new Post { PostID = 2,  PostedAt = DateTime.Now, Categories = new Collection<Category>{ _category2}};
            List<Post> posts = new List<Post> { _post1, _post2 };

            _unitOfWorkFactory = MockRepository.GenerateStub<IUnitOfWorkFactory>();
            _unitOfWork = MockRepository.GenerateStub<IUnitOfWork>();
            _postRepository = MockRepository.GenerateStub<IRepository<Post>>();
            _mapper = MockRepository.GenerateStub<IMapper<Post, PostViewModel>>();

            _unitOfWorkFactory.Stub(x => x.Create()).Return(_unitOfWork);
            _unitOfWork.Stub(x => x.GetRepository<Post>()).Return(_postRepository);
            _unitOfWork.Stub(x => x.Execute(Arg<Action>.Is.Anything)).WhenCalled(x => ((Action)x.Arguments[0])());

            _postRepository.Stub(y => y.AllIncluding(Arg<Expression<Func<Post, object>>>.Is.Anything)).Return(posts.AsQueryable());
        }
        protected override void Before_each()
        {
            _item = new AssaultItem {Description = "Description", Type = "Type", LoadValue = 2};

            _repo = Stub<IRepository<AssaultItem>>();
            _repo.Stub(x => x.Save(_item)).Return(9);
            _repo.Stub(x => x.GetById(9)).Return(_item);

            _service = new InventoryService(_repo);
        }
        public void SetUp()
        {
            _users = new List<User>();

            _repository = MockRepository.GenerateStub<IRepository>();
            _userService = new UserService(_repository);

            _curUser = null;

            _repository.Stub(r => r.Query<User>(null)).IgnoreArguments().Return(_users.AsQueryable());

            GivenUserDisplayName = "username";
            GivenUserEmail = "email";
            GivenUserUrl = "www";
            GivenTwitterUserName = "name";

            _curUser = _userService.AddOrUpdateUser(GivenUserEmail, GivenUserDisplayName, GivenUserUrl, GivenTwitterUserName);
        }
        public void SetUp()
        {
            _posts = new List<Post>();
            _users = new List<User>();
            _repository = MockRepository.GenerateStub<IRepository>();
            _resolver = MockRepository.GenerateStub<IUrlResolver>();
            _blogPostCommentService = MockRepository.GenerateStub<IBlogPostCommentService>();
            _userService = MockRepository.GenerateStub<IUserService>();
            _controller = new BlogPostController(_repository, _resolver, _blogPostCommentService, _userService);

            _post = new Post { Slug = _testSlug };
            _posts.Add(_post);

            _repository
               .Stub(r => r.Query<Post>(null))
               .IgnoreArguments()
               .Return(_posts.AsQueryable());

            _repository
               .Stub(r => r.Query<User>(null))
               .IgnoreArguments()
               .Return(_users.AsQueryable());

            _testSlug = "TESTSLUG";

            _invalidInput = new BlogPostCommentViewModel {Slug = _testSlug};

            _validInput = new BlogPostCommentViewModel
            {
                DisplayName = "username",
                Email = "email",
                Body = "body",
                Subscribed = true,
                Slug = _testSlug
            };
        }