Ejemplo n.º 1
0
        public async void GetAllPartnersTest()
        {
            var controller = new PartnerController(partnerService, mapper, appSettings);
            var partners   = await controller.GetAll();

            Assert.NotEmpty(partners);
        }
Ejemplo n.º 2
0
        public async void GetReturnValidResponseIfPartnerNotFoundTest()
        {
            var controller = new PartnerController(partnerService, mapper, appSettings);
            var response   = await controller.Get(-1);

            var notFoundResult = response as NotFoundObjectResult;

            Assert.NotNull(notFoundResult);
            Assert.Equal(404, notFoundResult.StatusCode);
        }
Ejemplo n.º 3
0
        public static string CheckPartners(PartnerController partnerController, List <Partner> expectedPartners)
        {
            // Get partners
            ViewResult viewResult = (ViewResult)partnerController.Index();

            if (viewResult.ViewData.Model.GetType() != typeof(List <Partner>))
            {
                return("PartnerController returned wrong action result. Expected: " + typeof(List <Partner>).ToString() + " Got: " + viewResult.ViewData.Model.GetType().ToString());
            }

            // Did the controller return any errors?
            if (partnerController.ViewData.ModelState.Count != 0)
            {
                return("PartnerController returned " + partnerController.ViewData.ModelState.Count.ToString()); // + " model errors: " + storeController.ViewData.ModelState[0].Errors[0]);
            }

            IList <Partner> actualPartners = (List <Partner>)viewResult.ViewData.Model;

            if (actualPartners.Count != expectedPartners.Count)
            {
                return("PartnerController returned the wrong number of stores.  Expected: " + expectedPartners.Count + " Got: " + actualPartners.Count.ToString());
            }

            // Check that each partner was found
            foreach (Partner expectedPartner in expectedPartners)
            {
                Partner foundPartner = null;
                foreach (Partner actualPartner in actualPartners)
                {
                    if (expectedPartner.Id == actualPartner.Id)
                    {
                        foundPartner = actualPartner;
                        break;
                    }
                }

                if (foundPartner == null)
                {
                    return("PartnerController didn't return partner " + expectedPartner.Id.ToString());
                }

                if (foundPartner.ExternalId != expectedPartner.ExternalId)
                {
                    return("ExternalId mismatch. Expected: " + expectedPartner.ExternalId + " Got: " + foundPartner.ExternalId);
                }
                if (foundPartner.Name != expectedPartner.Name)
                {
                    return("Name mismatch. Expected: " + expectedPartner.Name + " Got: " + foundPartner.Name);
                }
            }

            // All good
            return("");
        }
Ejemplo n.º 4
0
        public static string CheckPartnerApplications(PartnerController partnerController, Partner partner, List <ACSApplicationModel> expectedACSApplicationModels)
        {
            // Get partners applications
            ViewResult viewResult = (ViewResult)partnerController.Details(partner.Id, false);

            if (viewResult.ViewData.Model.GetType() != typeof(PartnerModel))
            {
                return("PartnerController returned wrong action result. Expected: " + typeof(PartnerModel).ToString() + " Got: " + viewResult.ViewData.Model.GetType().ToString());
            }

            // Did the controller return any errors?
            if (partnerController.ViewData.ModelState.Count != 0)
            {
                return("PartnerController returned " + partnerController.ViewData.ModelState.Count.ToString()); // + " model errors: " + storeController.ViewData.ModelState[0].Errors[0]);
            }

            PartnerModel actualPartnerModel = (PartnerModel)viewResult.ViewData.Model;

            // Check that the partner has the correct applications
            foreach (ACSApplicationModel expectedACSApplicationModel in expectedACSApplicationModels)
            {
                ACSApplication foundACSApplication = null;
                foreach (ACSApplication actualACSApplication in actualPartnerModel.ACSApplications)
                {
                    if (expectedACSApplicationModel.ACSApplication.Id == actualACSApplication.Id)
                    {
                        foundACSApplication = actualACSApplication;
                        break;
                    }
                }

                if (foundACSApplication == null)
                {
                    return("PartnerController didn't return partner application " + expectedACSApplicationModel.ACSApplication.Id.ToString());
                }

                if (foundACSApplication.ExternalApplicationId != expectedACSApplicationModel.ACSApplication.ExternalApplicationId)
                {
                    return("ExternalApplicationId mismatch. Expected: " + expectedACSApplicationModel.ACSApplication.ExternalApplicationId + " Got: " + foundACSApplication.ExternalApplicationId);
                }
                if (foundACSApplication.Name != expectedACSApplicationModel.ACSApplication.Name)
                {
                    return("Name mismatch. Expected: " + expectedACSApplicationModel.ACSApplication.Name + " Got: " + foundACSApplication.Name);
                }
                if (foundACSApplication.PartnerId != expectedACSApplicationModel.ACSApplication.PartnerId)
                {
                    return("PartnerId mismatch. Expected: " + expectedACSApplicationModel.ACSApplication.PartnerId + " Got: " + foundACSApplication.PartnerId);
                }
            }

            // All good
            return("");
        }
        private void BindGridView()
        {
            //SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CustomerConnectionString2"].ConnectionString);
            //SqlCommand cmd = new SqlCommand("select * from Partner", con);
            //DataTable dt = new DataTable();
            //SqlDataAdapter da = new SqlDataAdapter(cmd);
            //da.Fill(dt);
            PartnerController partnerController = new PartnerController(ConfigurationManager.ConnectionStrings["CustomerConnectionString2"].ConnectionString.ToString());

            GridView1.DataSource = partnerController.GetPartners();
            GridView1.DataBind();
        }
Ejemplo n.º 6
0
        public async void PutReturnValidResponseIfPartnerNotFoundDueToIdMismatchTest()
        {
            var controller = new PartnerController(partnerService, mapper, appSettings);
            var response   = await controller.Put(5, new UpdatePartnerViewModel()
            {
                Id = 4
            });

            var notFoundResult = response as NotFoundObjectResult;

            Assert.NotNull(notFoundResult);
            Assert.Equal(404, notFoundResult.StatusCode);
        }
Ejemplo n.º 7
0
        private void FirstPartner(string connectionString, Partner partner)
        {
            PartnerController partnerController = new PartnerController();

            partnerController.AndroAdminConnectionStringOverride = connectionString;

            // Add a partner
            ActionResult actionResult = partnerController.Add(partner);

            // Check for model errors
            string error = AndroAdminTestHelper.CheckForModelError(actionResult, partnerController);

            if (error.Length > 0)
            {
                Assert.Fail(error);
            }

            // Check to see if the partner exists
            error = AndroAdminTestHelper.CheckPartners(partnerController, new List <Partner> {
                partner
            });

            if (error.Length > 0)
            {
                Assert.Fail(error);
            }

            SyncHelper.ConnectionStringOverride = connectionString;
            string xml          = "";
            string errorMessage = AndroAdminSyncHelper.TryGetExportSyncXml(2, 3, out xml);

            Assert.AreEqual <string>("", errorMessage);

            string expectedXml2 =
                "<CloudSync>" +
                "<FromDataVersion>2</FromDataVersion>" +
                "<ToDataVersion>3</ToDataVersion>" +
                "<Stores />" +
                "<Partners>" +
                "<Partner>" +
                "<Id>1</Id>" +
                "<Name>test partner 1</Name>" +
                "<ExternalId>testpartner1</ExternalId>" +
                "<Applications />" +
                "</Partner>" +
                "</Partners>" +
                "</CloudSync>";

            Assert.AreEqual <string>(expectedXml2, xml, "Incorrect sync xml generated: " + xml);
        }
Ejemplo n.º 8
0
        public async void GetSinglePartnerTest()
        {
            var controller = new PartnerController(partnerService, mapper, appSettings);
            var response   = await controller.Get(1);

            var okResult = response as OkObjectResult;

            Assert.NotNull(okResult);
            Assert.Equal(200, okResult.StatusCode);
            Assert.NotNull(okResult.Value);

            var partner = okResult.Value as Partner;

            Assert.Equal(1, partner.Id);
        }
Ejemplo n.º 9
0
        public PartnerControllerTests()
        {
            _mockRepository = new MockRepository(MockBehavior.Strict);
            _mockMediator   = new Mock <IMediatorHandler>();

            // PartnerAppService
            _mockMapper            = new Mock <IMapper>();
            _mockPartnerRepository = new Mock <PartnerRepository>();
            _mockPartnerRepository.Setup(x => x.GetAll()).Returns(ValidCreatedPartners());

            _mockEventStoreRepository = new Mock <IEventStoreRepository>();
            _mockAppService           = new Mock <PartnerAppService>(_mockMapper.Object, _mockPartnerRepository.Object, _mockMediator.Object, _mockEventStoreRepository.Object);
            // PartnetController
            _mockNotificationHandler = new DomainNotificationHandler();
            _mockController          = new PartnerController(_mockAppService.Object, _mockNotificationHandler, _mockMediator.Object);
        }
Ejemplo n.º 10
0
        public async void PostCannotAddPartnerWithSameEmailTest()
        {
            var controller = new PartnerController(partnerService, mapper, appSettings);
            var model      = new CreatePartnerViewModel()
            {
                Name = "Ikea",
            };

            var response = await controller.Post(model);

            var okResult = response as BadRequestObjectResult;

            Assert.NotNull(okResult);
            Assert.Equal(400, okResult.StatusCode);
            Assert.NotNull(okResult.Value);
        }
Ejemplo n.º 11
0
 public void Setup()
 {
     _mockUserManager = new Mock <UserManager <ApplicationUser> >(
         new Mock <IUserStore <ApplicationUser> >().Object,
         new Mock <IOptions <IdentityOptions> >().Object,
         new Mock <IPasswordHasher <ApplicationUser> >().Object,
         new IUserValidator <ApplicationUser> [0],
         new IPasswordValidator <ApplicationUser> [0],
         new Mock <ILookupNormalizer>().Object,
         new Mock <IdentityErrorDescriber>().Object,
         new Mock <IServiceProvider>().Object,
         new Mock <ILogger <UserManager <ApplicationUser> > >().Object);
     _mockPlayerAccessLayer  = new  Mock <IPlayerAccessLayer>();
     _mockPartnerAccessLayer = new Mock <IPartnerAccessLayer>();
     _sut        = new PartnerController(_mockPartnerAccessLayer.Object, _mockPlayerAccessLayer.Object, _mockUserManager.Object);
     _createdAt  = DateTime.Now;
     _modifiedAt = DateTime.Now;
 }
Ejemplo n.º 12
0
        public async void PostTest()
        {
            var controller = new PartnerController(partnerService, mapper, appSettings);
            var model      = new CreatePartnerViewModel()
            {
                Name = "Amazon1",
            };
            var response = await controller.Post(model);

            var okResult = response as OkObjectResult;

            Assert.NotNull(okResult);
            Assert.Equal(200, okResult.StatusCode);
            Assert.NotNull(okResult.Value);

            var partner = okResult.Value as Partner;

            Assert.Equal(model.Name, partner.Name);
        }
Ejemplo n.º 13
0
        public async void AuthenticatePartner()
        {
            var controller = new PartnerController(partnerService, mapper, appSettings);
            var model      = new PartnerLoginViewModel()
            {
                Name     = "ikea",
                Password = "******",
            };
            var response = await controller.Authenticate(model);

            var okResult = response as OkObjectResult;

            Assert.NotNull(okResult);
            Assert.Equal(200, okResult.StatusCode);
            Assert.NotNull(okResult.Value);

            var token = okResult.Value as dynamic;

            Assert.NotNull(token);
        }
Ejemplo n.º 14
0
 public void Setup()
 {
     _mockMediator = new Mock <IMediator>(MockBehavior.Strict);
     _sut          = new PartnerController(_mockMediator.Object);
 }
Ejemplo n.º 15
0
        private void RemoveFirstPartnerApplicationStore(string connectionString, ACSApplicationModel application)
        {
            PartnerController partnerController = new PartnerController();

            partnerController.AndroAdminConnectionStringOverride = connectionString;

            // Remove the first store
            application.Stores[0].Selected = false;

            // Remove the first store from the application
            ActionResult actionResult = partnerController.ApplicationStores(application);

            // Check for model errors
            string error = AndroAdminTestHelper.CheckForModelError(actionResult, partnerController);

            if (error.Length > 0)
            {
                Assert.Fail(error);
            }

            // Check to see if the partner exists
            error = AndroAdminTestHelper.CheckPartners(partnerController, new List <Partner> {
                application.Partner
            });

            if (error.Length > 0)
            {
                Assert.Fail(error);
            }

            // Check to see if the application exists
            error = AndroAdminTestHelper.CheckPartnerApplications(partnerController, application.Partner, new List <ACSApplicationModel> {
                application
            });

            if (error.Length > 0)
            {
                Assert.Fail(error);
            }

            SyncHelper.ConnectionStringOverride = connectionString;
            string xml          = "";
            string errorMessage = AndroAdminSyncHelper.TryGetExportSyncXml(6, 7, out xml);

            Assert.AreEqual <string>("", errorMessage);

            string expectedXml2 =
                "<CloudSync>" +
                "<FromDataVersion>6</FromDataVersion>" +
                "<ToDataVersion>7</ToDataVersion>" +
                "<Stores />" +
                "<Partners>" +
                "<Partner>" +
                "<Id>1</Id>" +
                "<Name>test partner 1</Name>" +
                "<ExternalId>testpartner1</ExternalId>" +
                "<Applications>" +
                "<Application>" +
                "<Id>1</Id>" +
                "<ExternalApplicationId>TestExternalApplicationid</ExternalApplicationId>" +
                "<Name>TestName</Name>" +
                "<Sites>" +
                "123" +
                "</Sites>" +
                "</Application>" +
                "</Applications>" +
                "</Partner>" +
                "</Partners>" +
                "</CloudSync>";

            Assert.AreEqual <string>(expectedXml2, xml, "Incorrect sync xml generated: " + xml);
        }
 public PartnerControllerTest()
 {
     _fixture           = new PartnerControllerFixture();
     _fixture.Container = _fixture.Builder.Build();
     _controller        = _fixture.Container.Resolve <PartnerController>();
 }
Ejemplo n.º 17
0
 public void Startup()
 {
     _playerController  = GetComponent <PlayerController>();
     _partnerController = GetComponent <PartnerController>();
 }