protected void SetDataCollectionProfile(bool enable) { var profile = _dataCollectionProfile; profile.EnableAzureDataCollection = enable; DataCollectionController.WritePSDataCollectionProfile(AzureSession.Instance, profile); AzureSession.Instance.RegisterComponent(DataCollectionController.RegistryKey, () => DataCollectionController.Create(profile), true); }
private void Awake() { if (_instance != null && _instance != this) { Destroy(gameObject); } else { _instance = this; DontDestroyOnLoad(this); } }
public void SetUp() { _autoSubstitute = AutoSubstituteContainer.Create(); _controller = _autoSubstitute.GetController<DataCollectionController>(); _projectRepository = _autoSubstitute.Resolve<IProjectRepository>(); _dataCollectionRepository = _autoSubstitute.Resolve<IDataCollectionRepository>(); _context = _autoSubstitute.Resolve<ControllerContext>(); _form = _context.HttpContext.Request.Form; _lookup = _autoSubstitute.Resolve<ICurtinUserService>(); _fieldOfResearchRepository = _autoSubstitute.Resolve<IFieldOfResearchRepository>(); _socioEconomicObjectiveRepository = _autoSubstitute.Resolve<ISocioEconomicObjectiveRepository>(); _bus = _autoSubstitute.Resolve<IBus>(); }
public MainPage(IDataStore <StudentModel> dataStore) : base() { InitializeComponent(); _dataStore = dataStore; _studentRepository = new StudentRepository(_dataStore); _studentService = new StudentService(_studentRepository); _syncService = new SyncService(_studentService); _dataCollectionController = new DataCollectionController(_studentService); Title = "SignUp"; }
public void DataCollectionHandlesDirectoryExistenceErrors() { TestExecutionHelpers.SetUpSessionAndProfile(); Mock <IDataStore> mock = new Mock <IDataStore>(); mock.Setup(f => f.DirectoryExists(It.IsAny <string>())).Throws(new IOException("This should not be raised")); mock.Setup(f => f.FileExists(It.IsAny <string>())).Returns(true); mock.Setup(f => f.DeleteFile(It.IsAny <string>())); var oldDataStore = AzureSession.Instance.DataStore; AzureSession.Instance.DataStore = mock.Object; try { var controller = DataCollectionController.Create(AzureSession.Instance); var profile = controller.GetProfile(() => { }); DataCollectionController.WritePSDataCollectionProfile(AzureSession.Instance, profile); } finally { AzureSession.Instance.DataStore = oldDataStore; } }
public void DataCollectionHandlesWriteErrors() { TestExecutionHelpers.SetUpSessionAndProfile(); Mock <IDataStore> mock = new Mock <IDataStore>(); mock.Setup(f => f.DirectoryExists(It.IsAny <string>())).Returns(true); mock.Setup(f => f.FileExists(It.IsAny <string>())).Returns(false); mock.Setup(f => f.DeleteFile(It.IsAny <string>())); mock.Setup(f => f.WriteFile(It.IsAny <string>(), It.IsAny <byte[]>())).Throws(new ArgumentException("This exception should be caught")); mock.Setup(f => f.WriteFile(It.IsAny <string>(), It.IsAny <string>())).Throws(new ArgumentException("This exception should be caught")); mock.Setup(f => f.WriteFile(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Encoding>())).Throws(new ArgumentException("This exception should be caught")); var oldDataStore = AzureSession.Instance.DataStore; AzureSession.Instance.DataStore = mock.Object; try { DataCollectionController.WritePSDataCollectionProfile(AzureSession.Instance, new AzurePSDataCollectionProfile(true)); } finally { AzureSession.Instance.DataStore = oldDataStore; } }
public void DataCollectionHandlesSerializationErrors() { TestExecutionHelpers.SetUpSessionAndProfile(); MemoryDataStore dataStore; string oldFileValue = null; var dataCollectionPath = Path.Combine(AzureSession.Instance.ProfileDirectory, AzurePSDataCollectionProfile.DefaultFileName); var oldDataStore = AzureSession.Instance.DataStore; var memoryStore = oldDataStore as MemoryDataStore; if (memoryStore != null) { dataStore = memoryStore; if (dataStore.VirtualStore.ContainsKey(dataCollectionPath)) { oldFileValue = dataStore.VirtualStore[dataCollectionPath]; } } else { dataStore = new MemoryDataStore(); } dataStore.VirtualStore.Add(dataCollectionPath, "{{{{{{{{{{}}}--badly-formatted-file"); AzureSession.Instance.DataStore = dataStore; try { var controller = DataCollectionController.Create(AzureSession.Instance); var profile = controller.GetProfile(() => { }); DataCollectionController.WritePSDataCollectionProfile(AzureSession.Instance, profile); } finally { dataStore.VirtualStore[dataCollectionPath] = oldFileValue; AzureSession.Instance.DataStore = oldDataStore; } }
static void InitializeDataCollection(IAzureSession session) { session.RegisterComponent(DataCollectionController.RegistryKey, () => DataCollectionController.Create(session)); }
public void SetUp() { _studentServiceMock = new Mock <IStudentService>(MockBehavior.Strict); _dataCollectionController = new DataCollectionController(_studentServiceMock.Object); }