From 5b2464a8113fa4a68c8749b3553a5924d2131d9f Mon Sep 17 00:00:00 2001 From: 杨宇千 Date: Mon, 19 Aug 2019 15:43:47 +0800 Subject: Add avatar 304. --- Timeline.Tests/DatabaseTest.cs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Timeline.Tests/DatabaseTest.cs (limited to 'Timeline.Tests/DatabaseTest.cs') 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); + } + } +} -- cgit v1.2.3