public void Get_byIdAppExists_shouldReturnApp() { // Arrange var repository = new DapperAppRepository(Connection, AppTableName); var appId = Guid.NewGuid(); var serviceId = Guid.NewGuid(); var createdAt = DateTime.Now; const string secret = "testsecret"; const string name = "user1"; var app = new AppModel { AppId = appId, ServiceId = serviceId, Secret = secret, Enabled = true, CreatedAt = createdAt, Name = name, }; var id = repository.Insert(app); // Act var actual = repository.Get(id); // Assert Assert.AreEqual(appId, actual.AppId); Assert.AreEqual(serviceId, actual.ServiceId); Assert.AreEqual(secret, actual.Secret); Assert.AreEqual(createdAt.Date, actual.CreatedAt.Date); Assert.IsTrue(actual.Enabled); Assert.IsTrue(actual.Id > 0); Assert.AreEqual(name, actual.Name); }
public void Update_appDoesNotExist_shouldThrowException() { var repository = new DapperAppRepository(Connection, AppTableName); var app = CreateApp(); var id = repository.Insert(app); repository.Update(id + 1, app); }
public void Update_appExistsValidData_shouldUpdateApp() { var repository = new DapperAppRepository(Connection, AppTableName); var app = CreateApp(); app.Enabled = true; var id = repository.Insert(app); app = CreateApp(); app.Enabled = false; repository.Update(id, app); var actual = repository.Get(id); app.Id = id; Assert.AreEqual(app, actual); }
public void Update_invalidData_shouldThrowException() { var repository = new DapperAppRepository(Connection, AppTableName); var app = CreateApp(); var id = repository.Insert(app); repository.Update(id, null); }
public void Insert_dataIsNull_shouldNotInsertApp() { // Arrange var repository = new DapperAppRepository(Connection, AppTableName); // Act repository.Insert(null); // Assert // see expected exception }