diff options
author | 杨宇千 <crupest@outlook.com> | 2019-08-19 15:43:47 +0800 |
---|---|---|
committer | 杨宇千 <crupest@outlook.com> | 2019-08-19 15:43:47 +0800 |
commit | 5b2464a8113fa4a68c8749b3553a5924d2131d9f (patch) | |
tree | feaaef135731687eb16cd40556842cc8606cdaab /Timeline.Tests/DatabaseTest.cs | |
parent | 24fe6340ea69321ecafb57c8c5d6cd4b72f229b4 (diff) | |
download | timeline-5b2464a8113fa4a68c8749b3553a5924d2131d9f.tar.gz timeline-5b2464a8113fa4a68c8749b3553a5924d2131d9f.tar.bz2 timeline-5b2464a8113fa4a68c8749b3553a5924d2131d9f.zip |
Add avatar 304.
Diffstat (limited to 'Timeline.Tests/DatabaseTest.cs')
-rw-r--r-- | Timeline.Tests/DatabaseTest.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Timeline.Tests/DatabaseTest.cs b/Timeline.Tests/DatabaseTest.cs new file mode 100644 index 00000000..e280637c --- /dev/null +++ b/Timeline.Tests/DatabaseTest.cs @@ -0,0 +1,37 @@ +using FluentAssertions;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Linq;
+using Timeline.Entities;
+using Timeline.Tests.Mock.Data;
+using Xunit;
+
+namespace Timeline.Tests
+{
+ public class DatabaseTest : IDisposable
+ {
+ private readonly TestDatabase _database;
+ private readonly DatabaseContext _context;
+
+ public DatabaseTest()
+ {
+ _database = new TestDatabase();
+ _context = _database.DatabaseContext;
+ }
+
+ public void Dispose()
+ {
+ _database.Dispose();
+ }
+
+ [Fact]
+ public void DeleteUserShouldAlsoDeleteAvatar()
+ {
+ _context.UserAvatars.Count().Should().Be(2);
+ var user = _context.Users.First();
+ _context.Users.Remove(user);
+ _context.SaveChanges();
+ _context.UserAvatars.Count().Should().Be(1);
+ }
+ }
+}
|