Exemple #1
0
        public void TestMemoryContextDeviceDRListShallowClone()
        {
            Device device;
            List <DisturbanceRecording> drs;

            using (var context = ContextHelper.GetContextWithData())
            {
                var deviceContext = context.Devices.
                                    Include(x => x.DisturbanceRecordings)
                                    .FirstOrDefault();

                Assert.NotNull(deviceContext);
                device = DummyLoader.CloneDeviceShallow(context, deviceContext);
                drs    = DummyLoader.CloneAllDisturbanceRecordings(context, deviceContext);
            }
            //From Known values
            Assert.NotNull(device);
            Assert.NotNull(drs);
            Assert.NotEmpty(drs);

            var dr = drs.FirstOrDefault();

            //Currently only has 1 dr
            Assert.NotNull(dr);
            Assert.Equal(1, dr.Id);
            Assert.Equal("DR1", dr.Name);
            Assert.Equal(1, dr.DeviceId);
            Assert.Equal(DateTime.ParseExact("2017-12-31 13:26", "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture), dr.TriggerTime);
            Assert.Null(dr.Device);
        }
Exemple #2
0
        public void TestLocalDbContextDeviceDeepClone()
        {
            using (var context = new SystemContext())
            {
                try
                {
                    if (!context.Devices.Any())
                    {
                        return;
                    }
                }
                catch
                {
                    return;
                }

                var deviceLocalDB = context
                                    .Devices.AsNoTracking()
                                    .Include(x => x.DisturbanceRecordings).AsNoTracking()
                                    .FirstOrDefault();


                var deviceClone = DummyLoader.CloneDeviceDeep(context, deviceLocalDB);

                Assert.NotNull(deviceLocalDB);

                Assert.Equal(deviceLocalDB.Id, deviceClone.Id);
                Assert.Equal(deviceLocalDB.Bay, deviceClone.Bay);
                Assert.Equal(deviceLocalDB.DeviceType, deviceClone.DeviceType);
                Assert.Equal(deviceLocalDB.IPAddress, deviceClone.IPAddress);
                Assert.Equal(deviceLocalDB.IsConnected, deviceClone.IsConnected);
                Assert.Equal(deviceLocalDB.HasPing, deviceClone.HasPing);
                Assert.Equal(deviceLocalDB.Name, deviceClone.Name);
                Assert.Equal(deviceLocalDB.Station, deviceClone.Station);

                if (deviceLocalDB.DisturbanceRecordings == null ||
                    deviceLocalDB.DisturbanceRecordings.Count <= 0)
                {
                    return;
                }

                Assert.NotNull(deviceClone.DisturbanceRecordings);
                Assert.NotEmpty(deviceClone.DisturbanceRecordings);

                for (var i = 0; i < deviceLocalDB.DisturbanceRecordings.Count; i++)
                {
                    Assert.NotNull(deviceLocalDB.DisturbanceRecordings.ElementAt(i));
                    Assert.NotNull(deviceClone.DisturbanceRecordings.ElementAt(i));

                    Assert.Equal(deviceLocalDB.DisturbanceRecordings.ElementAt(i).Id, deviceClone.DisturbanceRecordings.ElementAt(i).Id);
                    Assert.Equal(deviceLocalDB.DisturbanceRecordings.ElementAt(i).Name, deviceClone.DisturbanceRecordings.ElementAt(i).Name);
                    Assert.Equal(deviceLocalDB.DisturbanceRecordings.ElementAt(i).DeviceId, deviceClone.DisturbanceRecordings.ElementAt(i).DeviceId);
                    Assert.Equal(deviceLocalDB.DisturbanceRecordings.ElementAt(i).TriggerTime, deviceClone.DisturbanceRecordings.ElementAt(i).TriggerTime);

                    //Failing:
                    //Assert.Equal(deviceLocalDB.DisturbanceRecordings.ElementAt(i).Device, deviceClone.DisturbanceRecordings.ElementAt(i).Device);
                }
            }
        }
Exemple #3
0
        public void TestLocalDbContextShallowDeviceClone()
        {
            Device deviceClone;

            int    id;
            string bay;
            string deviceType;
            string ipAddress;
            bool   isConnected;
            bool   hasPing;
            string name;
            string station;

            using (var context = new SystemContext())
            {
                try
                {
                    if (!context.Devices.Any())
                    {
                        return;
                    }
                }
                catch
                {
                    return;
                }

                var deviceLocalDB = context.Devices.FirstOrDefault();
                deviceClone = DummyLoader.CloneDeviceShallow(context, deviceLocalDB);
                Assert.NotNull(deviceLocalDB);

                id          = deviceLocalDB.Id;
                bay         = deviceLocalDB.Bay;
                deviceType  = deviceLocalDB.DeviceType;
                ipAddress   = deviceLocalDB.IPAddress;
                isConnected = deviceLocalDB.IsConnected;
                hasPing     = deviceLocalDB.HasPing;
                name        = deviceLocalDB.Name;
                station     = deviceLocalDB.Station;

                Assert.Equal(deviceLocalDB.Id, deviceClone.Id);
                Assert.Equal(deviceLocalDB.Bay, deviceClone.Bay);
                Assert.Equal(deviceLocalDB.DeviceType, deviceClone.DeviceType);
                Assert.Equal(deviceLocalDB.IPAddress, deviceClone.IPAddress);
                Assert.Equal(deviceLocalDB.IsConnected, deviceClone.IsConnected);
                Assert.Equal(deviceLocalDB.HasPing, deviceClone.HasPing);
                Assert.Equal(deviceLocalDB.Name, deviceClone.Name);
                Assert.Equal(deviceLocalDB.Station, deviceClone.Station);
            }

            Assert.Equal(id, deviceClone.Id);
            Assert.Equal(bay, deviceClone.Bay);
            Assert.Equal(deviceType, deviceClone.DeviceType);
            Assert.Equal(ipAddress, deviceClone.IPAddress);
            Assert.Equal(isConnected, deviceClone.IsConnected);
            Assert.Equal(hasPing, deviceClone.HasPing);
            Assert.Equal(name, deviceClone.Name);
            Assert.Equal(station, deviceClone.Station);
        }
        public void Will_Not_Attempt_To_Merge_Budgeted_Annual_Data_If_User_Has_Asked_For_No_Budgeting()
        {
            // Arrange
            const int no_budgeting_wanted = 0;
            var       budgeting_months    = new BudgetingMonths
            {
                Start_year                     = 2020,
                Next_unplanned_month           = 6,
                Last_month_for_budget_planning = no_budgeting_wanted
            };
            var loading_info = new DummyLoader().Loading_info();

            // Give it some annual budget data, otherwise it owuldn't do annual nudgeting anyway.
            loading_info.Annual_budget_data = new BudgetItemListData();
            var mock_input_output        = new Mock <IInputOutput>();
            var reconciliate             = new FileLoader(mock_input_output.Object, new Clock());
            var mock_spreadsheet         = new Mock <ISpreadsheet>();
            var mock_pending_file_io     = new Mock <IFileIO <BankRecord> >();
            var mock_pending_file        = new Mock <ICSVFile <BankRecord> >();
            var mock_actual_bank_file_io = new Mock <IFileIO <ActualBankRecord> >();
            var mock_bank_out_file_io    = new Mock <IFileIO <BankRecord> >();

            mock_pending_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), It.IsAny <char>()))
            .Returns(new List <BankRecord>());
            mock_actual_bank_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null))
            .Returns(new List <ActualBankRecord>());
            mock_bank_out_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null))
            .Returns(new List <BankRecord>());
            var mock_matcher = new Mock <IMatcher>();

            // Act
            var reconciliation_interface = reconciliate.Load <ActualBankRecord, BankRecord>(
                mock_spreadsheet.Object,
                mock_pending_file_io.Object,
                mock_pending_file.Object,
                mock_actual_bank_file_io.Object,
                mock_bank_out_file_io.Object,
                budgeting_months,
                loading_info,
                mock_matcher.Object);

            // Assert
            mock_spreadsheet
            .Verify(x => x.Add_budgeted_annual_data_to_pending_file(
                        It.IsAny <BudgetingMonths>(),
                        It.IsAny <ICSVFile <BankRecord> >(),
                        It.IsAny <BudgetItemListData>()),
                    Times.Never);
        }
        public void LoadFilesAndMergeData_WillNotLoadData_WhenTesting()
        {
            // Arrange
            var mock_input_output        = new Mock <IInputOutput>();
            var reconciliate             = new FileLoader(mock_input_output.Object, new Clock());
            var mock_spreadsheet         = new Mock <ISpreadsheet>();
            var mock_pending_file_io     = new Mock <IFileIO <BankRecord> >();
            var mock_pending_file        = new Mock <ICSVFile <BankRecord> >();
            var mock_actual_bank_file_io = new Mock <IFileIO <ActualBankRecord> >();
            var mock_bank_out_file_io    = new Mock <IFileIO <BankRecord> >();

            mock_actual_bank_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null))
            .Returns(new List <ActualBankRecord>());
            mock_bank_out_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null))
            .Returns(new List <BankRecord>());
            var budgeting_months = new BudgetingMonths {
                Start_year = 2020, Next_unplanned_month = 6, Last_month_for_budget_planning = 6
            };
            var loading_info = new DummyLoader().Loading_info();

            loading_info.File_paths.Main_path = "This is not a path";
            bool exception_thrown = false;
            var  mock_matcher     = new Mock <IMatcher>();

            // Act
            try
            {
                var reconciliation_interface = reconciliate.Load <ActualBankRecord, BankRecord>(
                    mock_spreadsheet.Object,
                    mock_pending_file_io.Object,
                    mock_pending_file.Object,
                    mock_actual_bank_file_io.Object,
                    mock_bank_out_file_io.Object,
                    budgeting_months,
                    loading_info,
                    mock_matcher.Object);
            }
            catch (DirectoryNotFoundException)
            {
                exception_thrown = true;

                // Clean up
                loading_info.File_paths.Main_path = ReconConsts.Default_file_path;
            }

            // Assert
            Assert.IsFalse(exception_thrown);
        }
Exemple #6
0
        public void TestMemoryContextDRShallowClone()
        {
            DisturbanceRecording dr;

            using (var context = ContextHelper.GetContextWithData())
            {
                var drContext = context.DisturbanceRecordings.FirstOrDefault();
                Assert.NotNull(drContext);
                dr = DummyLoader.CloneDisturbanceRecording(context, drContext);
            }
            //From Known values
            Assert.NotNull(dr);
            Assert.Equal(1, dr.Id);
            Assert.Equal("DR1", dr.Name);
            Assert.Equal(1, dr.DeviceId);
            Assert.Equal(DateTime.ParseExact("2017-12-31 13:26", "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture), dr.TriggerTime);
            Assert.Null(dr.Device);
        }
        public void SetupPlayerSettings()
        {
#if UNITY_EDITOR_WIN
            PlayerSettings.SetGraphicsAPIs(BuildTarget.StandaloneWindows64, new[] { m_PlayerSettingsDeviceType });
#elif UNITY_EDITOR_OSX
            PlayerSettings.SetGraphicsAPIs(BuildTarget.StandaloneOSX, new[] { m_PlayerSettingsDeviceType });
#endif
            m_Manager = ScriptableObject.CreateInstance <XRManagerSettings>();
            m_Manager.automaticLoading = false;

            m_Loaders = new List <XRLoader>();

            for (int i = 0; i < m_LoadersSupporteDeviceTypes.Length; i++)
            {
                DummyLoader dl = ScriptableObject.CreateInstance(typeof(DummyLoader)) as DummyLoader;
                dl.id = i;
                dl.supportedDeviceType = m_LoadersSupporteDeviceTypes[i];
                m_Loaders.Add(dl);
                m_Manager.loaders.Add(dl);
            }
        }
        public void M_WillNotDeleteUnreconciledRowsWhenMergingPendingWithUnreconciled()
        {
            // Arrange
            var mock_input_output        = new Mock <IInputOutput>();
            var reconciliate             = new FileLoader(mock_input_output.Object, new Clock());
            var mock_spreadsheet         = new Mock <ISpreadsheet>();
            var mock_pending_file_io     = new Mock <IFileIO <BankRecord> >();
            var mock_pending_file        = new Mock <ICSVFile <BankRecord> >();
            var mock_actual_bank_file_io = new Mock <IFileIO <ActualBankRecord> >();
            var mock_bank_out_file_io    = new Mock <IFileIO <BankRecord> >();
            var budgeting_months         = new BudgetingMonths {
                Start_year = 2020, Next_unplanned_month = 6, Last_month_for_budget_planning = 6
            };

            mock_pending_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), It.IsAny <char>()))
            .Returns(new List <BankRecord>());
            mock_actual_bank_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null))
            .Returns(new List <ActualBankRecord>());
            mock_bank_out_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null))
            .Returns(new List <BankRecord>());
            var loading_info = new DummyLoader().Loading_info();
            var mock_matcher = new Mock <IMatcher>();

            // Act
            var reconciliation_interface = reconciliate.Load <ActualBankRecord, BankRecord>(
                mock_spreadsheet.Object,
                mock_pending_file_io.Object,
                mock_pending_file.Object,
                mock_actual_bank_file_io.Object,
                mock_bank_out_file_io.Object,
                budgeting_months,
                loading_info,
                mock_matcher.Object);

            // Assert
            mock_spreadsheet
            .Verify(x => x.Delete_unreconciled_rows(It.IsAny <string>()),
                    Times.Never);
        }
    public IEnumerator LoadGame(DummyLoader loader)
    {
        var envScene = SceneManager.LoadSceneAsync(2, LoadSceneMode.Additive);

        envScene.allowSceneActivation = false;
        var gameScene = SceneManager.LoadSceneAsync(1, LoadSceneMode.Additive);

        gameScene.allowSceneActivation = false;
        while (gameScene.progress < 0.9f || envScene.progress < 0.9f)
        {
            yield return(null);
        }
        gameScene.allowSceneActivation = true;
        envScene.allowSceneActivation  = true;

        while (!gameScene.isDone || !envScene.isDone)
        {
            yield return(null);
        }
        SceneManager.UnloadSceneAsync(SceneManager.GetActiveScene());
        Destroy(loader.gameObject);
    }
Exemple #10
0
        public void TestMemoryContextDeviceShallowClone()
        {
            Device device;

            using (var context = ContextHelper.GetContextWithData())
            {
                var deviceContext = context.Devices.FirstOrDefault();
                Assert.NotNull(deviceContext);
                device = DummyLoader.CloneDeviceShallow(context, deviceContext);
            }
            //From Known values
            Assert.NotNull(device);
            Assert.Equal(1, device.Id);
            Assert.Equal("Bay1", device.Bay);
            Assert.Equal("REL670", device.DeviceType);
            Assert.Equal("192.168.1.1", device.IPAddress);
            Assert.Equal(1, device.Id);
            Assert.True(device.IsConnected);
            Assert.True(device.HasPing);
            Assert.Equal("IED1", device.Name);
            Assert.Equal("Station1", device.Station);
        }