forked from tobyash86/WebGoat.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlogEntryRepositoryTests.cs
More file actions
55 lines (43 loc) · 1.38 KB
/
BlogEntryRepositoryTests.cs
File metadata and controls
55 lines (43 loc) · 1.38 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Moq;
using System.Data.Entity.Core.Objects.DataClasses;
using System.Data.Entity.Infrastructure;
using WebGoatCore.Data;
using WebGoatCore.Models;
using static System.Runtime.InteropServices.JavaScript.JSType;
using NUnit.Framework;
namespace WebGoat.NET.Tests.BlogRepositoryTests;
[TestFixture]
public class Tests
{
Mock<NorthwindContext> _context;
[SetUp]
public void Setup()
{
_context = ContextSetup.CreateContext();
}
[Test]
public void GetBlogEntryTest()
{
var blogEntryRepo = new BlogEntryRepository(_context.Object);
var entry = blogEntryRepo.GetBlogEntry(1);
Assert.That(entry.Author, Is.EqualTo("admin"));
}
[Test]
public void TestEntryCreation()
{
var blogEntryRepo = new BlogEntryRepository(_context.Object);
var entry = blogEntryRepo.CreateBlogEntry("NEW ENTRY", "NEW ENTRY CONTENT", "me");
Assert.That(entry.Author, Is.EqualTo("me"));
}
[Test]
public void GetTopEntriesTest()
{
var blogEntryRepo = new BlogEntryRepository(_context.Object);
var entries = blogEntryRepo.GetTopBlogEntries();
Assert.That(entries.Count, Is.EqualTo(1));
}
}