Esempio n. 1
0
 private void OnDestroy()
 {
     if (state == LevelStateType.InProgress || state == LevelStateType.Quit)
     {
         AnalyticsController.SendLevelQuit(levelSettings.LevelName, secundsInLevel, GetPenguinsDataByState(PenguinsInLevel, PenguinController.EPenguinState.Lost).Count);
     }
 }
Esempio n. 2
0
        public async Task Post_ShouldSaveSave()
        {
            //Setup Analytics Repository
            var createmodel = new OneHourElectricityModel()
            {
                Id       = 1,
                KiloWatt = 2000,
                DateTime = DateTime.Now
            };

            _analyticsRepositoryMock.Setup(repo => repo.InsertAsync(It.IsAny <OneHourElectricity>()))
            .Returns((OneHourElectricity t) =>
            {
                t.Id       = createmodel.Id;
                t.DateTime = createmodel.DateTime;
                t.KiloWatt = createmodel.KiloWatt;
                t.PanelId  = panelId;
                return(Task.FromResult(1));
            });

            _anaController = new AnalyticsController(_analyticsRepositoryMock.Object, _panelRepositoryMock.Object);

            //Act
            var result = await _anaController.Post(panelId, createmodel);

            //Asserts
            var createResult = Assert.IsType <CreatedResult>(result);

            Assert.Equal(201, createResult.StatusCode);
            var resultModel = Assert.IsType <OneHourElectricityModel>(createResult.Value);

            Assert.Equal(createmodel.Id, resultModel.Id);
            Assert.Equal(createmodel.KiloWatt, resultModel.KiloWatt);
            Assert.Equal(createmodel.DateTime, resultModel.DateTime);
        }
Esempio n. 3
0
        public void Test_GetMaxAmountOfPeople()
        {
            //Arrange
            MockHandler mock = new MockHandler();
            Location    loc1 = new Location()
            {
                LocationId = 1, MaxCapacity = 75
            };
            Location loc2 = new Location()
            {
                LocationId = 2, MaxCapacity = 310
            };

            mock.Locations = new List <Location>()
            {
                loc1, loc2
            };
            AnalyticsController cont = new AnalyticsController(null, mock);

            //Act
            var result1 = cont.GetMaxAmountOfPeople(1);
            var result2 = cont.GetMaxAmountOfPeople(2);

            //Assert
            Assert.Equal(75, result1);
            Assert.Equal(310, result2);
        }
        public async Task Get_ShouldReturnOneHourElectricity()
        {
            // Arrange
            var panel = new Panel
            {
                Brand     = "Areva",
                Latitude  = 12.345678,
                Longitude = 98.7655432,
                Serial    = "AAAA1111BBBB2222"
            };

            var OneHourElectricity = new OneHourElectricity
            {
                Id       = 123,
                KiloWatt = 12345678,
                DateTime = DateTime.Now,
                PanelId  = "AAAA1111BBBB2222"
            };

            AnalyticsController mockController = MockPanelAndAnalyticsImplementation(panel, OneHourElectricity);

            // Act
            var result = await mockController.Get("AAAA1111BBBB2222");

            // Assert
            Assert.NotNull(result);
        }
        private static AnalyticsController MockPanelAndAnalyticsImplementation(Panel panel, OneHourElectricity OneHourElectricity)
        {
            var oneHourElectricitys = new List <OneHourElectricity>();

            oneHourElectricitys.Add(OneHourElectricity);
            IQueryable <OneHourElectricity> queryableElectricities = oneHourElectricitys.AsQueryable();

            // Force DbSet to return the IQueryable members of our converted list object as its data source
            var mockSet = new Mock <DbSet <OneHourElectricity> >();

            mockSet.As <IQueryable <OneHourElectricity> >().Setup(m => m.Provider).Returns(queryableElectricities.Provider);
            mockSet.As <IQueryable <OneHourElectricity> >().Setup(m => m.Expression).Returns(queryableElectricities.Expression);
            mockSet.As <IQueryable <OneHourElectricity> >().Setup(m => m.ElementType).Returns(queryableElectricities.ElementType);
            mockSet.As <IQueryable <OneHourElectricity> >().Setup(m => m.GetEnumerator()).Returns(queryableElectricities.GetEnumerator());

            var crossSolarDbContext = new CrossSolarDbContext();

            crossSolarDbContext.OneHourElectricitys = mockSet.Object;

            var mockAnalyticsRepository        = new Mock <IAnalyticsRepository>();
            var mockPanelRepository            = new Mock <IPanelRepository>();
            var mockPanelGenericRepository     = new Mock <GenericRepository <Panel> >();
            var mockAnalyticsGenericRepository = new Mock <GenericRepository <OneHourElectricity> >();

            var mockController = new AnalyticsController(mockAnalyticsRepository.Object, mockPanelRepository.Object);

            mockPanelRepository.Setup(x => x.GetAsync("AAAA1111BBBB2222")).Returns(Task.FromResult(panel));
            mockAnalyticsRepository.Setup(x => x.Query()).Returns(queryableElectricities);
            return(mockController);
        }
Esempio n. 6
0
        public void Test_GetMonthlyData()
        {
            //Arrange
            MockHandler mock = new MockHandler();

            mock.Histories = new List <History>();

            for (int i = 6; i < 11; i++)
            {
                DateTime dt = new DateTime(2020, 4, i, 10, 32, 30);
                History  h1 = new History()
                {
                    HistoryId = 1, LocationId = 5, Quantity = 10, TimeStamp = dt
                };
                History h2 = new History()
                {
                    HistoryId = 2, LocationId = 5, Quantity = 20, TimeStamp = dt
                };
                mock.Histories.Add(h1);
                mock.Histories.Add(h2);
            }

            AnalyticsController cont = new AnalyticsController(null, mock);

            //Act
            List <int> result = cont.GetMonthlyData(5, 0);

            //Assert
            foreach (int i in result)
            {
                Assert.Equal(15, i);
            }
        }
Esempio n. 7
0
        public void Test_GetCurrectAmountOfPeople()
        {
            //Arrange
            MockHandler mock = new MockHandler();
            History     his1 = new History()
            {
                LocationId = 1, Quantity = 10
            };
            History his2 = new History()
            {
                LocationId = 1, Quantity = 15
            };

            mock.Histories = new List <History>()
            {
                his1, his2
            };
            AnalyticsController cont = new AnalyticsController(null, mock);

            //Act
            var result      = cont.GetCurrectAmountOfPeople(1);
            var resultEmpty = cont.GetCurrectAmountOfPeople(2);

            //Assert
            Assert.Equal(15, result);
            Assert.Equal(0, resultEmpty);
        }
        public DoctorReservationsTable(
            Size tableSize,
            Point tableLocation,
            AnalyticsController controller
            )
        {
            // Init size; location; data source
            this.tableLocation = tableLocation;
            this.tableSize     = tableSize;
            this.controller    = controller;

            // Init table
            Table = new DataTable();

            // Init datagrid
            DataGrid                                    = new DataGridView();
            DataGrid.ReadOnly                           = true;
            DataGrid.AllowUserToAddRows                 = false;
            DataGrid.Size                               = this.tableSize;
            DataGrid.Location                           = this.tableLocation;
            DataGrid.RowTemplate.Height                 = 40;
            DataGrid.ColumnHeadersHeight                = 40;
            DataGrid.BackgroundColor                    = Colors.ALTO;
            DataGrid.ColumnCount                        = 2;
            DataGrid.Columns[0].Name                    = "Data";
            DataGrid.Columns[1].Name                    = "Rezervime të kryera";
            DataGrid.Columns[0].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
            DataGrid.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
            DataGrid.ColumnHeadersDefaultCellStyle.Font = new Font(Fonts.primary, 12, FontStyle.Bold);
            DataGrid.Font                               = new Font(Fonts.primary, 12, FontStyle.Regular);
            DataGrid.AutoSizeRowsMode                   = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
            DataGrid.MultiSelect                        = false;
            DataGrid.SelectionChanged                  += new EventHandler(onSelectionChanged);
        }
Esempio n. 9
0
        public void Test_GetAmountOfFavourites()
        {
            //Arrange
            MockHandler mock = new MockHandler();
            Favourite   fav1 = new Favourite()
            {
                LocationId = 1, Username = "******"
            };
            Favourite fav2 = new Favourite()
            {
                LocationId = 1, Username = "******"
            };
            Favourite fav3 = new Favourite()
            {
                LocationId = 1, Username = "******"
            };

            mock.Favourites = new List <Favourite> {
                fav1, fav2, fav3
            };
            AnalyticsController cont = new AnalyticsController(null, mock);

            //Act
            var result = cont.GetAmountOfFavourites(1);

            //Assert
            Assert.Equal(3, result);
        }
Esempio n. 10
0
            public void Queries_CorrectViewModel()
            {
                //Arrange
                var qRepository = new Mock <IQueryRepository>();
                var controller  = new AnalyticsController(null, null, null, null, null, qRepository.Object);

                qRepository.Setup(r => r.GetQueriesReportData()).Returns(new List <QueryReportDto>());

                EmulateControllerContext(controller, false);

                //Act
                var result = controller.Queries();

                //Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result is ViewResultBase);
                var viewResultBase = result as ViewResultBase;

                Assert.That(viewResultBase.Model, Is.Not.Null);
                Assert.That(viewResultBase.Model is List <QueriesAnalyticsViewModel>);
                var model = viewResultBase.Model as List <QueriesAnalyticsViewModel>;

                Assert.That(model.Count, Is.EqualTo(0));

                qRepository.Verify(r => r.GetQueriesReportData(), Times.Once());
            }
Esempio n. 11
0
    GivenValidQueryParamsWithoutStartAndEnd_WhenGetPayerPayeesBreakdownInvoked_ThenReturnsListOfAnalyticsPayerPayees()
    {
        var expectedTransactionType = TransactionType.Expense;

        var expectedAnalyticsPayerPayees = new List <AnalyticsPayerPayee>
        {
            new()
            {
                PayerPayeeName = "name",
                PayerPayeeId   = Guid.NewGuid(),
                TotalAmount    = 11234,
            }
        };

        _mockAnalyticsService.Setup(service =>
                                    service.GetPayerPayeeBreakdown(expectedTransactionType, DateTime.MinValue,
                                                                   DateTime.MaxValue))
        .ReturnsAsync(() => expectedAnalyticsPayerPayees);

        var controller = new AnalyticsController(_mockAnalyticsService.Object);
        var response   = await controller.GetPayerPayeesBreakdown(new GetPayerPayeesBreakdownQuery()
        {
            Type = expectedTransactionType
        });

        var objectResult = Assert.IsType <OkObjectResult>(response);

        var actualAnalyticsPayerPayees = objectResult.Value as List <AnalyticsPayerPayee>;

        Assert.Equal(expectedAnalyticsPayerPayees, actualAnalyticsPayerPayees);
    }
        public async Task Register_ShouldGetDayResult()
        {
            Mock <DbSet <Panel> > mockPanel = MockPanelRepository();
            Mock <DbSet <OneHourElectricity> > mockOneHourElectricity = MockDayResult();

            var mockContext = new Mock <CrossSolarDbContext>();

            mockContext.Setup(c => c.Set <Panel>()).Returns(mockPanel.Object);
            mockContext.Setup(c => c.Set <OneHourElectricity>()).Returns(mockOneHourElectricity.Object);

            var entityRepository    = new PanelRepository(mockContext.Object);
            var analyticsRepository = new AnalyticsRepository(mockContext.Object);

            var _analyticsController = new AnalyticsController(analyticsRepository, entityRepository);

            // Act
            var result = await _analyticsController.DayResults("AAAA1111BBBB2222");

            // Assert
            Assert.NotNull(result);
            var createdResult = result as OkObjectResult;

            Assert.NotNull(createdResult);
            Assert.Equal(200, createdResult.StatusCode);
        }
Esempio n. 13
0
        public void Test_GetGlossary()
        {
            //Arrange
            MockHandler mock     = new MockHandler();
            Glossary    glossary = new Glossary()
            {
                GlossaryId = 1, Dutch = "Hallo", English = "Hello", Spanish = "Ola"
            };

            mock.Glossaries = new List <Glossary>()
            {
                glossary
            };
            AnalyticsController cont = new AnalyticsController(null, mock);

            //Act
            var result1 = cont.GetGlossary("NL");
            var result2 = cont.GetGlossary("EN");
            var result3 = cont.GetGlossary("SP");

            //Assert
            Assert.Equal("Hallo", result1[1]);
            Assert.Equal("Hello", result2[1]);
            Assert.Equal("Ola", result3[1]);
        }
Esempio n. 14
0
    public async Task GivenValidQueryParameters_WhenGetPeriodicAggregatesInvoked_Then200OkReturned()
    {
        var controller = new AnalyticsController(_mockAnalyticsService.Object);
        var response   = await controller.GetPeriodicAggregates("type", "period", 1);

        var objectResult = Assert.IsType <OkResult>(response);
    }
 public AnalyticsControllerTest(IPanelRepository panelRepositoryMock, IAnalyticsRepository analyticsRepository, IDayAnalyticsRepository dayAnalyticsRepository)
 {
     _panelRepositoryMock    = panelRepositoryMock;
     _analyticsRepository    = analyticsRepository;
     _dayAnalyticsRepository = dayAnalyticsRepository;
     _controller             = new AnalyticsController(_analyticsRepository, _panelRepositoryMock, _dayAnalyticsRepository);
 }
        public async Task Register_ShouldInsertAnalytics()
        {
            var oneHourElectricityContent = new OneHourElectricityModel
            {
                Id       = 1,
                DateTime = new DateTime(2018, 1, 1),
                KiloWatt = 1500
            };

            var _panelRepositoryMock     = new Mock <IPanelRepository>();
            var _analiticsRepositoryMock = new Mock <IAnalyticsRepository>();

            var _analiticsController = new AnalyticsController(_analiticsRepositoryMock.Object, _panelRepositoryMock.Object);

            // Arrange

            // Act
            var result = await _analiticsController.Post("AAAA1111BBBB2222", oneHourElectricityContent);

            // Assert
            Assert.NotNull(result);

            var createdResult = result as CreatedResult;

            Assert.NotNull(createdResult);
            Assert.Equal(201, createdResult.StatusCode);
        }
Esempio n. 17
0
            public void AdverseEvents_CorrectViewModel()
            {
                //Arrange
                var vRepository    = new Mock <IVisitRepository>();
                var dfdRepository  = new Mock <IDemographicFormDataRepository>();
                var aefdRepository = new Mock <IAdverseEventFormDataRepository>();
                var controller     = new AnalyticsController(null, vRepository.Object, dfdRepository.Object, null, aefdRepository.Object,
                                                             null);

                vRepository.Setup(r => r.GetAeAnalyticsData()).Returns(new List <AeAnalyticsDto>());

                EmulateControllerContext(controller, false);

                //Act
                var result = controller.AdverseEvents();

                //Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result is ViewResultBase);
                var viewResultBase = result as ViewResultBase;

                Assert.That(viewResultBase.Model, Is.Not.Null);
                Assert.That(viewResultBase.Model is List <AdverseEventsAnalyticsViewModel>);
                var model = viewResultBase.Model as List <AdverseEventsAnalyticsViewModel>;

                Assert.That(model.Count, Is.EqualTo(0));

                vRepository.Verify(r => r.GetAeAnalyticsData(), Times.Once());
            }
Esempio n. 18
0
            public void Queries_CorrectViewModel_Mapping()
            {
                //Arrange
                var qRepository = new Mock <IQueryRepository>();
                var controller  = new AnalyticsController(null, null, null, null, null, qRepository.Object);

                var dto = GetQueryReportDto("Clinic1", "Super", "Doctor", FormType.Happiness, "QuestionCaption", false);

                qRepository.Setup(r => r.GetQueriesReportData()).Returns(new List <QueryReportDto> {
                    dto
                });

                EmulateControllerContext(controller, false);

                //Act
                var result = controller.Queries();

                //Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result is ViewResultBase);
                var viewResultBase = result as ViewResultBase;

                Assert.That(viewResultBase.Model, Is.Not.Null);
                Assert.That(viewResultBase.Model is List <QueriesAnalyticsViewModel>);
                var model = viewResultBase.Model as List <QueriesAnalyticsViewModel>;

                Assert.That(model.Count, Is.EqualTo(1));

                AssertQueriesAnalyticsViewModel(model[0], dto.ClinicName, dto.DoctorName, dto.FormType, dto.QuestionName, 1, 0);

                qRepository.Verify(r => r.GetQueriesReportData(), Times.Once());
            }
Esempio n. 19
0
 public AnalyticsControllerTests()
 {
     _analyticsController = new AnalyticsController(
         _analyticsRepositoryMock.Object,
         _panelRepositoryMock.Object,
         _dayAnalyticsRepositoryMock.Object
         );
 }
Esempio n. 20
0
 private void OnEnable()
 {
     if (GameState.CurrentState == GameStates.Game)
     {
         var buildVersionParam = new KeyValuePair <string, object>(BulbEvents.BuildVersionNumberParam, Application.version);
         AnalyticsController.LogCustomEvent(BulbEvents.Category_GeneralEvents, BulbEvents.Action_Game, BulbEvents.GameLaunched, buildVersionParam);
     }
 }
Esempio n. 21
0
 virtual protected void OnApplicationStart()
 {
     Application.targetFrameRate = 60;
     AnalyticsController.Init();
     AudioSessionUtil.ConfigureAudioSession();
     ImmersiveModeUtil.RegisterWithSceneNavigator();
     ImmersiveModeUtil.ActivateImmersiveMode();
     SagoBiz.Facade.OnApplicationStart();
 }
Esempio n. 22
0
 /// <summary>
 /// Private method, used by platform-specific extensions to report an app-open
 /// to the server.
 /// </summary>
 /// <param name="pushHash">An identifying hash for a given push notification,
 /// passed down from the server.</param>
 /// <returns>An Async Task that can be waited on or ignored.</returns>
 private static Task TrackAppOpenedWithPushHashAsync(string pushHash = null)
 {
     return(CurrentUserController.GetCurrentSessionTokenAsync(CancellationToken.None)
            .OnSuccess(t => {
         return AnalyticsController.TrackAppOpenedAsync(pushHash,
                                                        t.Result,
                                                        CancellationToken.None);
     }).Unwrap());
 }
Esempio n. 23
0
        public PuzzleEditor(CreatorController Controller, AnalyticsController analyticsController, Puzzle.Puzzle puzzle)
        {
            this.Controller          = Controller;
            this.AnalyticsController = analyticsController;
            this.Puzzle      = puzzle;
            this.ItemsPlaced = new List <Transform>();

            this.InitializeMovingItem();
        }
Esempio n. 24
0
        protected void txtDate_TextChanged(object sender, EventArgs e)
        {
            if (txtDate.Text != "")
            {
                try
                {
                    string           userID = Context.User.Identity.Name;
                    User             u      = new UserController().GetUser(userID);
                    string           owner  = string.Empty;
                    DashboardSummary d      = new DashboardSummary();
                    if (u.ClientID == 1)
                    {
                        owner = u.MobileNo;
                        //litSchoolName.Text = u.UserGroup.FirstOrDefault().Group_Name;
                        d = new AnalyticsController().GetDashboardSummary(Convert.ToDateTime(txtDate.Text), owner, u.ClientID);
                    }
                    else
                    {
                        //imgGroup.ImageUrl = "../images/" + u.ClientID.ToString() + ".jpg";
                        //string Query = string.Format("Select OrganizationName from Clients where ID=" + u.ClientID + "");
                        //SqlCommand cmd = new SqlCommand(Query);
                        //String constr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                        //SqlConnection con = new SqlConnection(constr);
                        //cmd.CommandType = CommandType.Text;
                        //cmd.Connection = con;
                        //con.Open();
                        //string ClientName = cmd.ExecuteScalar().ToString();
                        //con.Close();
                        //imgGroup.AlternateText = ClientName;
                        d = new AnalyticsController().GetDashboardSummary(Convert.ToDateTime(txtDate.Text), string.Empty, u.ClientID);
                    }
                    TotalStudentsonDate        = Convert.ToInt32(d.TotalStudents);
                    TotalMaleonDate            = Convert.ToInt32(d.TotalMale);
                    TotalFemaleonDate          = Convert.ToInt32(d.TotalFemale);
                    TotalStudentsPresentonDate = Convert.ToInt32(d.TotalStudentsPresent);
                    TotalMalePresentonDate     = Convert.ToInt32(d.TotalMalePresent);
                    TotalFemalePresentonDate   = Convert.ToInt32(d.TotalFemalePresent);
                    //TotalDistrictonDate = Convert.ToInt32(d.TotalDistrict);
                    //TotalSchoolonDate = Convert.ToInt32(d.TotalSchool);
                    TotalTeacheronDate        = Convert.ToInt32(d.TotalTeachers);
                    TotalTeacherPresentonDate = Convert.ToInt32(d.TotalTeachersPresent);

                    BindGraph(d);
                    BindGraphTeacher(d);
                    BindCasteChart(owner);
                    BindGenderChart(d, owner);
                    BindTrendLineChart(owner);
                    BindTrendLineChartTeacher(owner);
                    BindData(owner);
                }
                catch (Exception)
                {
                    General.ShowAlertMessage("Something is not write, no records found! Please try again.");
                }
            }
        }
Esempio n. 25
0
        public AnalyticsControllerTests() : base()
        {
            var contextOpions = new DbContextOptionsBuilder <CrossSolarDbContext>().UseSqlServer(ConnectionString).Options;
            var context       = new CrossSolarDbContext(contextOpions);

            _anlticsReposiitory = new AnalyticsRepository(context);
            _panelRepository    = new PanelRepository(context);
            _anlyticsController = new AnalyticsController(_anlticsReposiitory, _panelRepository);
            _panelController    = new PanelController(_panelRepository);
        }
        public AnalyticsControllerTest()
        {
            _analyticsRepository = new MockedAnalyticsRepository();

            _panelRepositoryMock = new MockPanelRepository();

            _dayAnalyticsRepository = new MockedDayAnalyticsRepository();

            _analyticsController = new AnalyticsController(_analyticsRepository, _panelRepositoryMock, _dayAnalyticsRepository);
        }
Esempio n. 27
0
    public void DoNewGame()
    {
        GamePlay.autoWinShown         = false;
        GamePlay.magicWandDialogShown = false;
        AnalyticsController.sendEvent("StartGame", new Dictionary <string, object> {
            { "Type", GameManager.Instance.GameType }, { "Mode", GameManager.Instance.GetModeGame() }
        });

        DoNewGame(false);
    }
Esempio n. 28
0
 public void onInterstitialClosed()
 {
     //StartCoroutine(InterstitialClosedCoroutine());
     //Pause(false);
     //point
     //StartCoroutine(UpdateTimer());
     timer       = 0f;
     timerTicked = false;
     AnalyticsController.sendEvent("InterstitialClosed");
 }
Esempio n. 29
0
 public MainApplication()
 {
     InitializeComponent();
     _transactionController = new TransactionController();
     _accountController     = new AccountController();
     _analyticsController   = new AnalyticsController();
     _reportController      = new DataImportController();
     _expenditureController = new ExpenditureController();
     _dataImportController  = new DataImportController();
     PopulationAll();
 }
Esempio n. 30
0
 // Use this for initialization
 void Start()
 {
     if (instance != null)
     {
         Destroy(gameObject);
         return;
     }
     instance = this;
     DontDestroyOnLoad(gameObject);
     //googleAnalytics.StartSession();
 }