public void GetByUniqueKey_ShouldReturnNull_WhenWrongKey() { // Arrange var context = GetContext(TestData.attachedDocs); var repo = new SqlAttachedDocRepo(context); var markId = TestData.marks[0].Id; var designation = TestData.attachedDocs[0].Designation; // Act var attachedDoc1 = repo.GetByUniqueKey(999, designation); var attachedDoc2 = repo.GetByUniqueKey(markId, "NotFound"); // Assert Assert.Null(attachedDoc1); Assert.Null(attachedDoc2); context.Database.EnsureDeleted(); context.Dispose(); }
public void GetByUniqueKey_ShouldReturnAttachedDoc() { // Arrange var context = GetContext(TestData.attachedDocs); var repo = new SqlAttachedDocRepo(context); int id = _rnd.Next(1, TestData.attachedDocs.Count()); var foundAttachedDoc = TestData.attachedDocs.FirstOrDefault(v => v.Id == id); var markId = foundAttachedDoc.Mark.Id; var designation = foundAttachedDoc.Designation; // Act var attachedDoc = repo.GetByUniqueKey(markId, designation); // Assert Assert.Equal(id, attachedDoc.Id); context.Database.EnsureDeleted(); context.Dispose(); }