public void CanUpdateFile() { Mock<IFileRepository> mock = new Mock<IFileRepository>(); File fileToUpdate = new File { Id = 1, FilePath = "" }; FileController controller = new FileController(mock.Object); controller.Put(fileToUpdate); }
public void CanAddFile() { Mock<IFileRepository> mock = new Mock<IFileRepository>(); File fileToAdd = new File { FilePath = "" }; FileController controller = new FileController(mock.Object); controller.Post(fileToAdd); }
public async Task Get_EmptyUri_BadRequest() { ILogger <FileController> _loggerStub = Substitute.For <ILogger <FileController> >(); ILoadBalancerFactory factoryStub = Substitute.For <ILoadBalancerFactory>(); IFileHttpClient fileClientStub = Substitute.For <IFileHttpClient>(); var controller = new FileController(_loggerStub, factoryStub, fileClientStub); var result = await controller.Get(""); Assert.IsTrue(result is BadRequestResult); }
public ActionResult Create(Publication publication, HttpPostedFileBase cover, HttpPostedFileBase avatar) { publication.Id = Guid.NewGuid().ToString(); publication.CreatedAt = DateTime.Now; publication.UpdatedAt = DateTime.Now; publication.Cover = FileController.SaveFile(avatar).Path; publication.Logo = FileController.SaveFile(cover).Path; _context.Publications.Add(publication); _context.Complete(); return(RedirectToAction("Index")); }
/// <summary> /// Ctor is private in a singleton implementation. /// </summary> private CodeFlowViewModel() { // Instantiate the file controller. _fileController = new FileController(new FileStoreController()); // Instantiate the history controller. _historyController = new HistoryController(); // Wire up the NotifyDirty event. ModelBase.NotifyDirty += NotifyDirtyHandler; }
public async Task Post_ShouldReturnCorrectResult(IFixture fixture, FileController sut) { // arrange var files = fixture.Build <IFormFileCollection>().Create(); // act var actual = await sut.Post(files); // assert actual.ShouldBeOfType <FileStreamResult>(); }
public async Task DownloadFile_Without_Token_Should_Return_Forbidden(string token) { // arrange var sut = new FileController(null, null, null, null, null, null, null, null, null, null, null, null, null, null); // act var result = await sut.DownloadFile(1, token); // assert ((NegotiatedContentResult <string>)result).StatusCode.Should().Be(HttpStatusCode.Forbidden); }
public void Test_LoadPlayerData_ListLength2() { ctrl = new FileController(); ctrl.SaveFile(); ctrl.LoadFile(); int actual = ctrl.fileData.Count; int expected = 2; Assert.AreEqual(actual, expected); }
public void FileController_UpdateSEO_IfErrorIsThrownOnSaveReturnValueContainsMessage() { FileController fileController = GetFileController(); var mediaFile = new MediaFile(); A.CallTo(() => fileAdminService.SaveFile(mediaFile)).Throws(new Exception("Test exception")); fileController.UpdateSEO(mediaFile, "test-title", "test-description") .Should() .Be("There was an error saving the SEO values: Test exception"); }
public void GetAssetInfo_With_Exception_In_StatusClient_Should_ReThrow_Exception_For_GlobalExceptionHandler() { // arrange var mockHit = new Mock <IHit <ElasticArchiveRecord> >(); mockHit.SetupGet(m => m.Source).Returns(new ElasticArchiveRecord { ArchiveRecordId = "1", MetadataAccessTokens = new List <string> { "Ö1" }, PrimaryDataDownloadAccessTokens = new List <string> { "BAR" }, PrimaryData = new List <ElasticArchiveRecordPackage> { new ElasticArchiveRecordPackage { PackageId = "a valid packageid", FileCount = 1 } } }); var mockElasticResponse = new Mock <ISearchResponse <ElasticArchiveRecord> >(); mockElasticResponse.SetupGet(m => m.Hits).Returns(new List <IHit <ElasticArchiveRecord> > { mockHit.Object }); var elasticServiceMock = Mock.Of <IElasticService>(setup => setup.QueryForId <ElasticArchiveRecord>(It.IsAny <int>(), It.IsAny <UserAccess>()) == new ElasticQueryResult <ElasticArchiveRecord> { Response = mockElasticResponse.Object }); var cacheHelperMock = Mock.Of <ICacheHelper>(); var statusClientMock = new Mock <IRequestClient <GetAssetStatusRequest, GetAssetStatusResult> >(); statusClientMock.Setup(m => m.Request(It.IsAny <GetAssetStatusRequest>(), It.IsAny <CancellationToken>())) .Throws(new Exception("Error in StatusClient")); var sut = new FileController(null, statusClientMock.Object, null, null, null, elasticServiceMock, null, null, null, cacheHelperMock, null, null, null, null); sut.GetUserAccessFunc = userId => new UserAccess(userId, "BAR", null, null, false); // act var action = (Func <Task <IHttpActionResult> >)(async() => await sut.GetAssetInfo(1)); // assert action.Should().Throw <Exception>("the global exception handler is used to avoid publish callstacks").WithMessage("Error in StatusClient"); }
public MainWindowViewModel() { _fileController = new FileController(); _debtorOrCreditors = new ObservableCollection <DebtorOrCreditor>(); var savedDebtorOrCreditors = _fileController.ReadFromFile(); _debtorOrCreditors = savedDebtorOrCreditors; this.ClosingCommand = new DelegateCommand <object>(this.OnWindowClosing); }
public void GetP4FileWithNotExistingIdTest(int no) { var fileController = new FileController(mockHttpContextAccessor.Object, p4Context); var result = fileController.GetFile(no); var objectResult = Assert.IsType <BadRequestObjectResult>(result); var model = Assert.IsAssignableFrom <string>(objectResult.Value); Assert.Equal($"A megadott azonosítóval nincs letárolt fájl! Id: {no}", model); }
public void FileController_UpdateSEO_ShouldSetTitleAndDescriptionFromInputs() { FileController fileController = GetFileController(); var mediaFile = new MediaFile(); fileController.UpdateSEO(mediaFile, "test-title", "test-description"); mediaFile.Title.Should().Be("test-title"); mediaFile.Description.Should().Be("test-description"); }
public void File_Get_InValidFileDataReturnNullShouldReturnEmpty() { _MockFileDataModel.Setup(x => x.Get(It.IsAny <string>())).Returns((List <FileMetaData>)null); _MockGenericHelper.Setup(x => x.GetUserID()).Returns(Guid.NewGuid().ToString()); var model = new FileController(_MockFileDataModel.Object, _MockLogger.Object, _MockMessageQueueHelper.Object, _MockAppConfig.Object, _MockFileUploadHelper.Object, _MockGenericHelper.Object); var result = model.Get() as OkNegotiatedContentResult <FileViewModel[]>; Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult <FileViewModel[]>)); }
public void File_Delete_Valid() { _MockGenericHelper.Setup(x => x.GetUserID()).Returns(Guid.NewGuid().ToString()); _MockMessageQueueHelper.Setup(x => x.PushMessage <FileMetaData>(It.IsAny <IApplicationConfig>(), It.IsAny <FileMetaData>(), It.IsAny <string>())); var model = new FileController(_MockFileDataModel.Object, _MockLogger.Object, _MockMessageQueueHelper.Object, _MockAppConfig.Object, _MockFileUploadHelper.Object, _MockGenericHelper.Object); var result = model.Delete(Guid.NewGuid()) as OkResult; Assert.IsInstanceOfType(result, typeof(OkResult)); }
public void tryUnzipFile(FileController file) { file.gameObject.SetActive(false); DesktopSystemManager.DSM.freeUpFile(file); // If the file was selected, stop dragging if (LastClickedFile == fileID) { DragController.DC.stopSelectionFollowingMouse(); } }
public ChosseFileinDB(ClassFile file, ClassFolder folder, int result) { InitializeComponent(); File = new ClassFile(); File = file; Folder = folder; Result = result; allfile = new List <ClassFile>(); allfile = FileController.getListFiles(); displayFile(); }
public async Task FileController_Upload_ThrowException() { var mock = new Mock <IUploadHelper>(); mock.Setup(m => m.UploadFileAsync(null, It.IsAny <string>())).ThrowsAsync(new Exception()); var fileController = new FileController(mock.Object); var result = await fileController.Upload(); Assert.IsInstanceOfType(result, typeof(ExceptionResult)); }
/// <summary> /// Вывод результатов. /// </summary> /// <param name="fc"> Объект контроллера. </param> public static void Print(FileController fc) { fc.FindMaxTen(fc.File); for (int i = 0; i < 10; i++) { Console.WriteLine($"\"{fc.File.MaxKeys[i]}\" встречается {fc.File.MaxValues[i]} раз"); } TimeSpan timeTaken = timer.Elapsed; Console.WriteLine($"Врем выполнения: {timeTaken.ToString(@"m\:ss\.fff")}"); Console.Write("Для выхода из программы нажмите любую клавишу."); }
// //==================================================================================================== // public override string CreateUploadFieldPathFilename(string tableName, string fieldName, int recordId, string filename, CPContentBaseClass.FieldTypeIdEnum fieldType) { if ((fieldType == CPContentBaseClass.FieldTypeIdEnum.File) || (fieldType == CPContentBaseClass.FieldTypeIdEnum.FileImage)) { // // -- the only two valid fieldtypes. All the other file-field types are text fields backed with a file, like .css return(FileController.getVirtualRecordUnixPathFilename(tableName, fieldName, recordId, filename)); } // // -- techically, this is a mistake the developer made calling this method. These types do not upload return(FileController.getVirtualRecordUnixPathFilename(tableName, fieldName, recordId, fieldType)); }
[MenuItem("Window/Autoya/Generate Test AssetBundles")] public static void BuildAssetBundles() { var currentPlatform = EditorUserBuildSettings.activeBuildTarget; var currentPlatformStr = currentPlatform.ToString(); var assetBundleExportPath = FileController.PathCombine("AssetBundles", currentPlatformStr); Directory.CreateDirectory(assetBundleExportPath); BuildPipeline.BuildAssetBundles(assetBundleExportPath, BuildAssetBundleOptions.None, currentPlatform); }
public HttpResponseMessage Download(string references) { FileInfo compressFile = imageUpload.Download(imageUpload.StringtoList(references)); imageUpload.DeleteFileByDate(compressFile); FileController _fileController = new FileController(); HttpResponseMessage response = _fileController.GetDownloadResponse(compressFile); return(response); }
/// <summary> /// Создание начальных директорий. /// </summary> private void InitializeDirectories() { try { FileController.Init(); } catch (Exception exception) { MessageBox.Show("Не получается создать стартовую директорию!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void CreateInstanceOfFileService_WhenFileServiceParameterIsNotNull() { // Arrange var fileService = new Mock <IFileService>(); // Act var fileController = new FileController(fileService.Object); // Act and Assert Assert.That(fileController, Is.Not.Null); Assert.IsInstanceOf <FileController>(fileController); }
static void BeforInit() { //データがなかったら作成する if (!File.Exists(FileController.GetFilePath(m_textName))) { Debug.Log($"{FileController.GetFilePath(m_textName)}のファイルが見つかりませんでした。ファイルを作ります"); SettingData settingData = new SettingData(GravityController.ControllerState.Joystick, 0.5f); //デフォルトを0.5f音量 Debug.Log(JsonUtility.ToJson(settingData)); FileController.TextSave(m_textName, JsonUtility.ToJson(settingData)); } }
public static void Main() { MainWindow mainWindow = new MainWindow(); FileController controller = new FileController(new Vocabulary(), mainWindow); App app = new App { MainWindow = mainWindow }; mainWindow.Show(); app.Run(); }
public static void PathWriting(TextBox tb, ListView lv) { try { lv.ItemsSource = FileController.GetDirectoryContent(tb.Text); } catch (Exception) { MessageBox.Show("Acces denied/ Wrong path"); tb.Text = ""; } }
public void CloseDocumentTest() { FileController fileController = Container.GetExportedValue <FileController>(); IFileService fileService = Container.GetExportedValue <IFileService>(); MockDocumentType documentType = new MockDocumentType("Mock Document", ".mock"); fileController.Register(documentType); fileController.New(documentType); fileService.CloseCommand.Execute(null); Assert.IsFalse(fileService.Documents.Any()); }
public void SetUp() { _logger = Substitute.For <ILogger <FileController> >(); _mediator = Substitute.For <IMediator>(); _fileController = new FileController(_logger, _mediator) { ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() } }; }
public void FileController_Delete_CallsDeleteFileOnFileService() { FileController fileController = GetFileController(); var mediaFile = new MediaFile(); mediaFile.MediaCategory = new MediaCategory { Id = 1 }; fileController.Delete_POST(mediaFile); A.CallTo(() => fileAdminService.DeleteFile(mediaFile)).MustHaveHappened(); }
static MinecraftTypeParser() { Instance = new MinecraftTypeParser(); if (FileController.Exists("minecraftTypes")) { LoadFromDisc(); } else { DownloadItems(); } }
private void lockFiles(List <string> list_imageFiles) { FileController fileController = new FileController(); foreach (string filePath in list_imageFiles) { FileInfo file = new FileInfo(filePath); string GUID = fileController.Move_To_Vault(file); sysController.AddRecord(file.FullName, GUID); } MessageBox.Show("Total Files Locked : " + list_imageFiles.Count(), "Files Locked Successfully!", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public void CanGetFileByTagIds() { File[] expected = { new File { Id = 1 }, new File { Id = 2 } }; Mock<IFileRepository> mock = new Mock<IFileRepository>(); mock.Setup(f => f.GetByTags(It.IsAny<int[]>())) .Returns(expected); FileController controller = new FileController(mock.Object); Assert.AreEqual(expected, controller.Get(new [] {1, 2})); }
private static FileController GetFileController() { fileAdminService = A.Fake<IFileAdminService>(); var fileController = new FileController(fileAdminService); return fileController; }
void InitializeScene() { // Remove any created items from last game and reset variables if (players != null) { foreach (var p in players) { Destroy(p.baseObject); } players = null; } playerTurnIndex = 0; turnState = TurnState.Starting; // Initialize references guiController = GetComponent<GUIController>(); editorController = GetComponent<EditorController>(); fileController = GetComponent<FileController>(); // Add back editorController if it is not there (it was destoryed for performance ) if (editorController == null) { editorController = gameObject.AddComponent<EditorController>(); } blockPrefabs = new List<GameObject>(); blockPrefabs.Add(GameObject.Find("PB_Square")); blockPrefabs.Add(GameObject.Find("PB_Hexagon")); blockPrefabs.Add(GameObject.Find("PB_Trapezoid")); blockPrefabs.Add(GameObject.Find("PB_Rhombus")); blockPrefabs.Add(GameObject.Find("PB_Triangle")); blockPrefabs.Add(GameObject.Find("PB_ThinRhombus")); blockImages = new List<Texture2D>(); blockImages.Add((Texture2D)Resources.Load("Texture/FlatSquare")); blockImages.Add((Texture2D)Resources.Load("Texture/FlatHexagon")); blockImages.Add((Texture2D)Resources.Load("Texture/FlatTrapezoid")); blockImages.Add((Texture2D)Resources.Load("Texture/FlatRhombus")); blockImages.Add((Texture2D)Resources.Load("Texture/FlatTriangle")); blockImages.Add((Texture2D)Resources.Load("Texture/FlatThinRhombus")); mouseHelper = GetComponent<MouseHelper>(); baseHolder = GameObject.Find("BaseHolder"); factory = GameObject.Find("Factory"); prefabBase = GameObject.Find("PB_Base"); activeBaseMarker = GameObject.Find("ActiveBaseMarker"); cameraObj = GameObject.Find("GameCamera"); gameCamera = cameraObj.camera; radarCameraObj = GameObject.Find("RadarCamera"); radarCamera = radarCameraObj.camera; SetRadarCameraVisible(false); shooter = GameObject.Find("Shooter"); // Hide Factory if (hideFactory) { factory.transform.position = new Vector3(0, 100, 0); } }
public void IsInstanceOfIFileController_GetsCorrectConstructorParams_ReturnsInstanceOfIFileController() { FileController fc = new FileController(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.BaseDirectory); Assert.IsInstanceOf(typeof(IFileController), fc); }
public void IsInstanceOfIFileController_GetsIncorrectConstructorParams_ThrowsArgumentException() { FileController fc = null; Assert.Throws<ArgumentException>(() => fc = new FileController("test incorrect path", AppDomain.CurrentDomain.BaseDirectory)); }