public void TestFindNotesByUser() { INoteAccessor accessor = this._provider.GetService <INoteAccessor>(); IUserAccessor userAccessor = this._provider.GetService <IUserAccessor>(); var ian = userAccessor.FindUser("ian"); var ianNotes = accessor.FindNotes(ian); var zach = userAccessor.FindUser("zach"); var zachNotes = accessor.FindNotes(zach); Assert.Equal(5, ianNotes.Count); Assert.Equal(2, zachNotes.Count); Assert.Throws <ArgumentException>(() => { accessor.FindNotes((Contracts.DTO.User)null); }); }
public void TestRemoveNote() { INoteAccessor accessor = this._provider.GetService <INoteAccessor>(); IUserAccessor userAccessor = this._provider.GetService <IUserAccessor>(); PersistenceContext context = this._provider.GetService <PersistenceContext>(); IUnitOfWork unit = this._provider.GetService <IUnitOfWork>(); var kauf = accessor.FindPin("kauf"); var kaufNotes = accessor.FindNotes(kauf); Assert.Equal(3, kaufNotes.Count); Assert.Equal(7, context.Notes.Count()); accessor.RemoveNote(kaufNotes.First()); unit.Commit(); kaufNotes = accessor.FindNotes(kauf); Assert.Equal(2, kaufNotes.Count); Assert.Equal(6, context.Notes.Count()); Assert.Throws <ArgumentException>(() => { accessor.RemoveNote(null); unit.Commit(); }); Assert.Throws <ArgumentException>(() => { accessor.RemoveNote(new Contracts.DTO.Note()); unit.Commit(); }); Assert.Throws <ArgumentException>(() => { accessor.RemoveNote(new Contracts.DTO.Note() { NoteId = "NOTAREALNOTE" }); unit.Commit(); }); }
public void TestFindNotesByPin() { INoteAccessor accessor = this._provider.GetService <INoteAccessor>(); var kaufNotes = accessor.FindNotes(new Contracts.DTO.Pin() { PinId = "kauf" }); Assert.Equal(3, kaufNotes.Count); var destinationNotes = accessor.FindNotes(new Contracts.DTO.Pin() { PinId = "dest" }); Assert.Equal(2, destinationNotes.Count); Assert.Throws <ArgumentException>(() => { accessor.FindNotes((Contracts.DTO.Pin)null); }); }
public void TestAddNote() { INoteAccessor accessor = this._provider.GetService <INoteAccessor>(); IUserAccessor userAccessor = this._provider.GetService <IUserAccessor>(); PersistenceContext context = this._provider.GetService <PersistenceContext>(); IUnitOfWork unit = this._provider.GetService <IUnitOfWork>(); var pin = accessor.FindPin("kauf"); var ian = userAccessor.FindUser("ian"); Assert.Equal(7, context.Notes.Count()); Assert.Equal(5, accessor.FindNotes(ian).Count); accessor.AddNote(new Contracts.DTO.Note() { Added = DateTime.Now, BelongsTo = pin.PinId, Content = "Testing software late at night, stupid Raikes School curriculum" }); unit.Commit(); Assert.Equal(8, context.Notes.Count()); Assert.Throws <ArgumentException>(() => { accessor.AddNote(null); unit.Commit(); }); Assert.Throws <ArgumentException>(() => { accessor.AddNote(new Contracts.DTO.Note() { NoteId = "TN4", Content = "Bad note - duplicate ID", BelongsTo = pin.PinId }); unit.Commit(); }); Assert.Throws <ArgumentException>(() => { accessor.AddNote(new Contracts.DTO.Note() { Content = "Bad note - no pin" }); unit.Commit(); }); }
public void TestFindNotesByRegion() { INoteAccessor accessor = this._provider.GetService <INoteAccessor>(); IUserAccessor userAccessor = this._provider.GetService <IUserAccessor>(); var ian = userAccessor.FindUser("ian"); var zach = userAccessor.FindUser("zach"); Assert.Equal(3, accessor.FindNotes(_campus, ian).Count); Assert.Equal(0, accessor.FindNotes(_bottoms, ian).Count); Assert.Equal(5, accessor.FindNotes(_lincoln, ian).Count); Assert.Equal(0, accessor.FindNotes(_south, ian).Count); Assert.Equal(0, accessor.FindNotes(_campus, zach).Count); Assert.Equal(2, accessor.FindNotes(_bottoms, zach).Count); Assert.Equal(2, accessor.FindNotes(_lincoln, zach).Count); Assert.Equal(0, accessor.FindNotes(_south, zach).Count); Assert.Throws <ArgumentException>(() => { accessor.FindNotes(null, ian); }); Assert.Throws <ArgumentException>(() => { accessor.FindNotes(_campus, null); }); Assert.Throws <ArgumentException>(() => { accessor.FindNotes(null, null); }); }