public void SaveFindOneDeviceTest() { var mockSetting = new MockSettingRepository(); mockSetting.InitializeTestDataBasic(); AppGlobal.Init(mockSetting); IUnityContainer myContainer = new UnityContainer(); myContainer.RegisterType <ILogManager, LogManager_UWP_audit_memory>(); var logManager = myContainer.Resolve <LogManager_UWP_audit_memory>(); //fileHelper.FileSystemStorage = MockFileSystemStorage.MockFileSystem; MockFileSystemStorage.InitMockFileSystem(); logManager.AuditLogger.InitializeAuditLogAsync().Wait(); var dalRepository = new DalRepository(logManager); dalRepository.InitilizeDbAsync().Wait(); var dateTime = DateTimeOffset.Now; var device1 = new Entity.Devices.Device(); device1.DeviceId = "173bc09720324709a5f34359d66328e8"; device1.Name = "Device 2"; dalRepository.SaveAsync(device1).Wait(); var count = dalRepository.CountAsync <Entity.Devices.Device>().Result; Assert.True(count == 1); var device1Result = dalRepository.FindOneAsync <Entity.Devices.Device>(x => x.DeviceId == device1.DeviceId).Result; Assert.True(device1.Name == device1Result.Name); var device2Resutl = dalRepository.FindOneAsync <Entity.Devices.Device>(x => x.DeviceId == "XXXX").Result; Assert.True(device2Resutl == null); }
public void BasicTest() { IUnityContainer myContainer = new UnityContainer(); myContainer.RegisterType <ILogManager, LogManager_UWP_audit_memory>(); var logManager = myContainer.Resolve <LogManager_UWP_audit_memory>(); NLog.GlobalDiagnosticsContext.Set("user", "UnitTest"); //fileHelper.FileSystemStorage = MockFileSystemStorage.MockFileSystem; var mockSetting = new MockSettingRepository(); mockSetting.InitializeTestDataBasic(); AppGlobal.Init(mockSetting); var testValue = AppGlobal.Device.DeviceFolderGuid; var expectValue = mockSetting.GetPersistText("CurrentFoldersDevicesGuid", "NONE"); Assert.Equal(expectValue, testValue); logManager.FlushBuffer(); }
public void SaveGetTest() { var mockSetting = new MockSettingRepository(); AppGlobal.Init(mockSetting); IUnityContainer myContainer = new UnityContainer(); myContainer.RegisterType <ILogManager, LogManager_UWP_audit_memory>(); var logManager = myContainer.Resolve <LogManager_UWP_audit_memory>(); //fileHelper.FileSystemStorage = MockFileSystemStorage.MockFileSystem; MockFileSystemStorage.InitMockFileSystem(); mockSetting.InitializeTestDataBasic(); logManager.AuditLogger.InitializeAuditLogAsync().Wait(); var log = logManager.GetLog("C00000"); var deviceGuid = Guid.NewGuid().ToString("N"); var userGuid = Guid.NewGuid().ToString("N"); log.AuditAsync("CODE1", DataTypeEnum.Audit, deviceGuid, userGuid, new System.Collections.Generic.Dictionary <string, string>() { { "ke1", "value1" }, { "key2", "value2" } }).Wait(); log.AuditAsync("CODE2", DataTypeEnum.Audit, deviceGuid, userGuid, null).Wait(); log.AuditAsync("CODE3", DataTypeEnum.Audit, deviceGuid, userGuid, null).Wait(); log.AuditAsync("CODE4", DataTypeEnum.Audit, deviceGuid, userGuid, null).Wait(); var dateTime = DateTimeOffset.Now; var audits = logManager.AuditLogger.GetAuditsAsync(dateTime.Year, dateTime.Month).Result; var count = logManager.AuditLogger.CountAsync(dateTime.Year, dateTime.Month).Result; Assert.True(count == 5); Assert.True(count == audits.ToList().Count()); logManager.FlushBuffer(); }
public void CreateDeviceTest() { IUnityContainer myContainer = new UnityContainer(); myContainer.RegisterType <ILogManager, LogManager_UWP_audit_memory>(); var logManager = myContainer.Resolve <LogManager_UWP_audit_memory>(); //fileHelper.FileSystemStorage = MockFileSystemStorage.MockFileSystem; MockFileSystemStorage.InitMockFileSystem(); var mockSetting = new MockSettingRepository(); mockSetting.InitializeTestDataBasic(); AppGlobal.Init(mockSetting); logManager.AuditLogger.InitializeAuditLogAsync(); Windows.Storage.StorageFolder appDataFolder = Windows.Storage.ApplicationData.Current.LocalFolder; var repository = new FileRepository(logManager, MockFileSystemStorage.MockFileSystem, appDataFolder.Path); //var dalRepository = new DalRepository(logManager, fileHelper); //DeviceService deviceService = new DeviceService(logManager, fileRepository, dalRepository); //var device = deviceService.CreateNewDevice(DeviceTypeEnum.Uwp).Result; }