Ejemplo n.º 1
0
        public void ShouldSearchForPetsByARangeOfDecisionDates()
        {
            //AAA
            //1. Arrange
            mockPetRepo = new Mock <IPetRepo>();

            List <Pet> mockPets = CreateMockPetData();

            mockPetRepo.Setup(m => m.ListAllPets()).Returns(mockPets); //Logic will be in the controller method

            mockPetRepo.Setup(m => m.ListAllClients()).Returns(new List <Client>());

            int expectedNumberOfPetsInList = 3;

            PetController petController = new PetController(mockPetRepo.Object);

            //DropDownList for owners [Text = Full name of the owner ? Value = Id]
            string   clientID  = null;
            string   petType   = null;
            DateTime?startDate = new DateTime(2020, 10, 1);
            DateTime?endDate   = new DateTime(2020, 10, 31);

            SearchForPetsViewModel viewModel = new SearchForPetsViewModel();

            viewModel.ClientID       = clientID;
            viewModel.PetType        = petType;
            viewModel.StartDate      = startDate;
            viewModel.EndDate        = endDate;
            viewModel.UserFirstVisit = "No";

            //2. Act
            ViewResult             result      = petController.SearchForPets(viewModel) as ViewResult;
            SearchForPetsViewModel resultModel = result.Model as SearchForPetsViewModel;
            int actualNumberOfPetsInList       = resultModel.ResultPetList.Count;

            //3. Assert
            Assert.Equal(expectedNumberOfPetsInList, actualNumberOfPetsInList);
        }
Ejemplo n.º 2
0
        public async Task GetPetPerPageReturnsPerPage()
        {
            var repo     = new FakeModelRepo();
            var repoMock = new Mock <IPetRepository>();
            var logger   = new Mock <ILogger>();

            logger.Setup(x => x.Path).Returns("sample");
            repoMock.Setup(x => x.CountPets()).Returns(repo.CountPets());
            repoMock.Setup(x => x.GetPetPerPage(1, 10)).Returns(repo.GetPetPerPage(1, 10));
            var controller = new PetController(repoMock.Object, logger.Object);

            var result = await controller.GetPetsPerPage(1) as OkObjectResult;

            if (result != null)
            {
                dynamic obj = new DynamicObjectResultValue(result.Value);


                Assert.Equal(2, obj.totalCount);
                Assert.Equal(1, obj.totalPages);
                Assert.IsType <List <Pet> >(obj.pets);
            }
        }
Ejemplo n.º 3
0
        public async void BulkInsert_Errors()
        {
            PetControllerMockFacade mock = new PetControllerMockFacade();

            var mockResponse = new Mock <CreateResponse <ApiPetResponseModel> >(new FluentValidation.Results.ValidationResult());

            mockResponse.SetupGet(x => x.Success).Returns(false);

            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiPetRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiPetResponseModel> >(mockResponse.Object));
            PetController controller = new PetController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var records = new List <ApiPetRequestModel>();

            records.Add(new ApiPetRequestModel());
            IActionResult response = await controller.BulkInsert(records);

            response.Should().BeOfType <ObjectResult>();
            (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity);
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiPetRequestModel>()));
        }
Ejemplo n.º 4
0
        public void PetControllerAddsPet()
        {
            const int petId    = 100;
            var       expected = new Pet(petId, "Zoey", "Cat");
            var       mockRepo = new Mock <IPetRepository>();

            mockRepo.Setup(r => r.GetPet(petId)).Returns(expected);
            var controller = new PetController(mockRepo.Object);

            var postResult = controller.Post(expected);

            Assert.IsInstanceOf <OkObjectResult>(postResult);

            var getResult = controller.Get(expected.Id);

            Assert.IsInstanceOf <OkObjectResult>(getResult);
            var okResult = (OkObjectResult)getResult;

            var pet = (Pet)okResult.Value;

            Assert.AreEqual(expected.Id, pet.Id);
            Assert.AreEqual(expected.Name, pet.Name);
            Assert.AreEqual(expected.Type, pet.Type);
        }
Ejemplo n.º 5
0
 public override void Enter()
 {
     pet    = GetComponent <PetController>();
     player = FindObjectOfType <PlayerController>();
 }
 public PetControllerTests()
 {
     repo      = Substitute.For <IPetRepository>();
     underTest = new PetController(repo);
 }
Ejemplo n.º 7
0
 // Start is called before the first frame update
 void Start()
 {
     PC = GetComponent <PetController>();
 }
Ejemplo n.º 8
0
 internal PassiveGear(PetController controller) : base(controller, true, 1)
 {
     Type = GearType.PASSIVE;
 }
Ejemplo n.º 9
0
        public PetController CreatePetController()
        {
            var petController = new PetController(_petService.Object, _webClient.Object, _serialise.Object);

            return(petController);
        }
Ejemplo n.º 10
0
 public SleepState(PetController pet) : base(pet)
 {
 }
Ejemplo n.º 11
0
 private void Awake()
 {
     pet = GetComponentInParent <PetController>();
 }
Ejemplo n.º 12
0
 public PetControllerTest()
 {
     Controller = new PetController(new PetQuery(), new CreatePetCommandHandler(), new DeletePetCommandHandler());
 }
Ejemplo n.º 13
0
 internal GuardGear(PetController controller) : base(controller, true, 1)
 {
     Type = GearType.GUARD;
 }
Ejemplo n.º 14
0
 public PathFollower(PetController controller)
 {
     Controller = controller;
 }
Ejemplo n.º 15
0
 void Start()
 {
     winText.SetText("");
     petController = FindObjectOfType <PetController>();
 }
Ejemplo n.º 16
0
 public AttentiveState(PetController pet) : base(pet)
 {
 }
Ejemplo n.º 17
0
 private void OnClickAnimalItem(PetController data)
 {
     DataManager.GetInstance().SetNowSelectedPetData(data.GetPetData());
     UISystem.OpenDialog(Define.DialogType.InvenDialog);
 }
Ejemplo n.º 18
0
 public IdleState(PetController pet) : base(pet)
 {
 }
Ejemplo n.º 19
0
 public KamikazeGear(PetController controller, bool enabled, int level, int amount = 1) : base(controller, enabled, level, amount)
 {
 }
 public void Setup()
 {
     petController = new PetController();
     petOne        = new Pet("Iggy The Lizard", PetType.Reptile, 100, 150, 2.5, 2.5, "UserABC123");
     petThree      = new Pet("Sammy the Stegosaurus", PetType.Dinosaur, 1000, 50, 100, 1, "UserCDE456");
 }
Ejemplo n.º 21
0
 public void SetUpPet(PetStat stat, PetController controller)
 {
     m_PetStat       = stat;
     m_PetController = controller;
 }
Ejemplo n.º 22
0
 public State(PetController pet)
 {
     this.pet = pet;
 }
Ejemplo n.º 23
0
 void Start()
 {
     instance = this;
 }
Ejemplo n.º 24
0
 //Tets class constructor
 public PetControllerTests()
 {
     underTest = new PetController();
 }
Ejemplo n.º 25
0
 internal AutoLootGear(PetController controller) : base(controller, true, 1)
 {
     Type = GearType.AUTO_LOOT;
 }
 public AutoResourceCollectionGear(PetController controller) : base(controller, true, 3)
 {
     Type = GearType.AUTO_RESOURCE_COLLECTION;
 }
Ejemplo n.º 27
0
 public ComboRepairGear(PetController controller) : base(controller, true, 3)
 {
     Type = GearType.COMBO_SHIP_REPAIR;
 }