-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTransactionScopeAspectTests.cs
38 lines (34 loc) · 1.07 KB
/
TransactionScopeAspectTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shop.Core.Aspects.Postsharp.TransactionAspects;
using Shop.Core.Tests.Db.EntityFramework.Configuration;
using Shop.Entities.Concrete;
using System;
using System.Linq;
namespace Shop.Core.Tests.AspectTests.Postsharp
{
[TestClass]
public class TransactionScopeAspectTests
{
private CoreTestContext _context;
[TestInitialize]
public void InitDatabase()
{
_context = new CoreTestContext();
_context.Database.Initialize(true);
}
[TestMethod]
public void TestEntityFrameworkTransactionMethod()
{
try { EntityFrameworkTransactionMethod(); }
catch { /* ignored */ }
Assert.AreEqual(0, _context.Categories.Count());
}
[TransactionScopeAspect]
private void EntityFrameworkTransactionMethod()
{
_context.Categories.Add(new Category { Name = "category1", });
_context.SaveChanges();
throw new Exception("test exception");
}
}
}