public async Task VisitorPictureRepository_DeleteVisitorPicture_Deleted_NotFail_Test() { var context = new MyCompanyContext(); IVisitorPictureRepository target = new VisitorPictureRepository(new MyCompanyContext()); var visitorId = context.Visitors.FirstOrDefault().VisitorId; System.Text.ASCIIEncoding encoder = new System.Text.ASCIIEncoding(); var newVisitorPicture = new VisitorPicture() { VisitorId = visitorId, PictureType = PictureType.Big, Content = encoder.GetBytes("sample"), }; int visitorPictureId = await target.AddAsync(newVisitorPicture); int expected = context.VisitorPictures.Count() - 1; await target.DeleteAsync(visitorPictureId); int actual = context.VisitorPictures.Count(); Assert.AreEqual(expected, actual); }
public async Task VisitorPictureRepository_DeleteVisitorPicture_NoExists_NotFail_Test() { var context = new MyCompanyContext(); int expected = context.VisitorPictures.Count(); IVisitorPictureRepository target = new VisitorPictureRepository(new MyCompanyContext()); await target.DeleteAsync(-1); int actual = context.VisitorPictures.Count(); Assert.AreEqual(expected, actual); }
public async Task VisitorPictureRepository_AddOrUpdateNewEntity_NotFail_Test() { var context = new MyCompanyContext(); var target = new VisitorPictureRepository(new MyCompanyContext()); var visitorId = await AddVisitor(); int expected = context.VisitorPictures.Count(); var pictureToRemove = context.VisitorPictures .First(p => p.VisitorId == visitorId && p.PictureType == PictureType.Small); await target.DeleteAsync(pictureToRemove.VisitorPictureId); var encoder = new System.Text.ASCIIEncoding(); await target.AddOrUpdateAsync(visitorId, PictureType.Small, encoder.GetBytes("sample")); int actual = context.VisitorPictures.Count(); Assert.AreEqual(expected, actual); }