public void DbExistsChecks() { CreateVersionChecker(); VersionChecker.CheckAndUpdate(); FileSystemServiceMock.Verify(fss => fss.CheckFileExists(DbService.DatabaseName), Times.Once); }
public void CopyOfOldDbDeletesWhenMigrationsSuccessfulDone() { var appVersion = new Version(2, 1); var currentDbVersion = "2.0"; CreateVersionChecker(appVersion); DbServiceMock.Setup(ds => ds.SettingsGetValue(SettingsType.DBVersion)).Returns(currentDbVersion); MessageBoxServiceMock.Setup(mbs => mbs.AskWarningQuestion(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <object>())).Returns(true); VersionChecker.CheckAndUpdate(); FileSystemServiceMock.Verify(fss => fss.DeleteFile(DbService.DatabaseCopyName), Times.Once); }
public void DbRevertedOnMigrationError() { var appVersion = new Version(2, 1); var currentDbVersion = "2.0"; CreateVersionChecker(appVersion); DbServiceMock.Setup(ds => ds.SettingsGetValue(SettingsType.DBVersion)).Returns(currentDbVersion); DbServiceMock.Setup(ds => ds.MigrateFrom2_0to2_1()).Throws <Exception>(); MessageBoxServiceMock.Setup(mbs => mbs.AskWarningQuestion(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <object>())).Returns(true); InvokeAndSwallowException(() => VersionChecker.CheckAndUpdate()); FileSystemServiceMock.Verify(fss => fss.CreateFileCopy(DbService.DatabaseCopyName, DbService.DatabaseName, true), Times.Once); FileSystemServiceMock.Verify(fss => fss.DeleteFile(DbService.DatabaseCopyName), Times.Once); }
public async Task WebClientInsertAsyncTest() { var baseUrl = "http://localhost:8889/"; var fileEntityService = new FileEntityServiceMock(); var fileSystemService = new FileSystemServiceMock(); using (var app = CreateWebApp(baseUrl, resolver => resolver.RegisterFactory <FileController>(() => new FileController(fileEntityService, fileSystemService)))) { using (var client = new HttpClient()) { var response = await client.PostAsync($"{baseUrl}api/file?name=Testfile10&fileType=Document", new ByteArrayContent(Encoding.UTF8.GetBytes("Test"))); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); var file = await response.Content.ReadAsAsync <FileReference>(); Assert.AreEqual(FileType.Document, file.FileType); Assert.AreEqual("Testfile10", file.Name); Assert.IsTrue(file.Path.EndsWith(file.Id.ToString())); response = await client.PostAsync($"{baseUrl}api/file?name=Testfile10&fileType=Document", new ByteArrayContent(Encoding.UTF8.GetBytes("Test"))); Assert.AreEqual(HttpStatusCode.Conflict, response.StatusCode); } } }
protected override void Setup() { base.Setup(); FileSystemServiceMock.Setup(fss => fss.CheckFileExists(It.IsAny <string>())).Returns(true); }