Example #1
0
        public async Task ImportByModel_Test()
        {
            var testingModel = DeviceImport_TestData.GetTestImportModel();
            var testImport   = await testingInstance.ImportByModelAsync(testingModel);

            var expectedDevices     = testingModel.Devices.OrderBy(x => x.Id).ToList();
            var devicesInRepository = await devicesRepository.GetAllAsync();

            var devicesInRepositorySorted = devicesInRepository.OrderBy(x => x.Id).ToList();

            Assert.Equal(expectedDevices, devicesInRepositorySorted);
        }
Example #2
0
        public async Task ImportByFormFileAsync_Test()
        {
            var currentDirectory   = Directory.GetCurrentDirectory();
            var testingFilePath    = Path.Combine(currentDirectory, "..", "..", "..", "DeviceImport", "TestingDevicesFile.json");
            var testingFormFile    = FormFileMockFactory.CreateFormFileByFileInfo("application/json", new FileInfo(testingFilePath));
            var expectedNewDevices = DeviceImport_TestData.GetTestImportModel().Devices.OrderBy(x => x.Id).ToList();
            var result             = await testingInstance.ImportByFormFileAsync(testingFormFile);

            var allDevices = await devicesRepository.GetAllAsync();

            var allDevicesResult = allDevices.OrderBy(x => x.Id).ToList();

            Assert.Equal(expectedNewDevices, allDevicesResult);
        }
Example #3
0
        public async Task ImportByJsonText_Test_ShouldSucceed()
        {
            var testingModel            = DeviceImport_TestData.GetTestImportModel();
            var testingModelAsValidJson = JsonSerializer.Serialize(testingModel);
            var testImport = await testingInstance.ImportByJsonTextAsync(testingModelAsValidJson);

            var expectedDevices     = testingModel.Devices.OrderBy(x => x.Id);
            var devicesInRepository = await devicesRepository.GetAllAsync();

            var devicesInRepositorySorted = devicesInRepository.OrderBy(x => x.Id);

            var expected = expectedDevices.ToList();
            var result   = devicesInRepositorySorted.ToList();

            Assert.Equal(expected, result);
        }