Beispiel #1
0
        public async Task WhenSetFileUploadCompleteCalled_ItShouldUpdateTheDatabase()
        {
            await this.DatabaseTestAsync(async testDatabase =>
            {
                this.target = new SetFileUploadCompleteDbStatement(testDatabase);

                await this.CreateUserAsync(testDatabase);
                await this.AddFileAsync(testDatabase);
                await testDatabase.TakeSnapshotAsync();

                const long NewLength = 11111L;

                await this.target.ExecuteAsync(FileId, NewLength, TimeStamp);

                var expectedFile = new File(
                    FileId.Value,
                    UserId.Value,
                    ChannelId.Value,
                    FileState.UploadComplete,
                    UploadStartedTimeStamp,
                    TimeStamp,
                    null,
                    null,
                    null,
                    FileNameWithoutExtension,
                    FileExtension,
                    NewLength,
                    Purpose,
                    null,
                    null);

                using (var databaseContext = testDatabase.CreateContext())
                {
                    var newFile = databaseContext.Files.Find(FileId.Value);
                    Assert.IsTrue(newFile.UploadStartedDate < newFile.UploadCompletedDate);
                    Assert.IsTrue((DateTime.UtcNow - newFile.UploadStartedDate) < TimeSpan.FromMinutes(5));
                    Assert.IsTrue((newFile.UploadCompletedDate - newFile.UploadStartedDate) < TimeSpan.FromMinutes(5));
                }

                return(new ExpectedSideEffects
                {
                    Update = expectedFile,
                });
            });
        }
Beispiel #2
0
        public async Task WhenSetFileUploadCompleteCalledTwice_ItShouldHaveNoEffect()
        {
            await this.DatabaseTestAsync(async testDatabase =>
            {
                this.target = new SetFileUploadCompleteDbStatement(testDatabase);

                await this.CreateUserAsync(testDatabase);
                await this.AddFileAsync(testDatabase);

                const long NewLength = 11111L;

                await this.target.ExecuteAsync(FileId, NewLength, TimeStamp);
                await testDatabase.TakeSnapshotAsync();

                await this.target.ExecuteAsync(FileId, NewLength, TimeStamp);
                return(ExpectedSideEffects.None);
            });
        }
Beispiel #3
0
 public void Initialize()
 {
     this.target = new SetFileUploadCompleteDbStatement(new Mock <IFifthweekDbConnectionFactory>(MockBehavior.Strict).Object);
 }