public void AddUser_User_UserIsAdd() { // Method AddUser_User_UserIsAdd() // - AddUser: Name of the method being tested // - User: Scenario (state) under which the method is being tested // - UserIsAdd: Expected behavior when the scenario is invoked // ARRANGE // - Set up the context, instantiate the repository, create an user to add // ACT // - Call the AddUser method on the repository // ASSERT // - Check if user was added // ARRANGE PGContext context = GetDbContext(); UserEntity user = new UserEntity(id: "0000", name: "TEST"); // ACT EntityEntry <UserEntity> entry = context.Users.Add(entity: user); int numberOfStateEntries = context.SaveChanges(); // var entryEntity = context.Entry(entity: user); // entryEntity.State = EntityState.Added; // ASSERT Assert.AreEqual(expected: 1, actual: context.Users.Count()); }
public void Add() { var newItem = new PG { Id = 3, PGTest = "tuttoVaBene" }; PGContext.PGs.Add(newItem); PGContext.SaveChanges(); }
private void Seed(PGContext context) { List <UserEntity> userLst = new() { new UserEntity(id: "0000", name: "TEST"), new UserEntity(id: "0001", name: "TEST"), new UserEntity(id: "0002", name: "TEST") }; context.Users.AddRange(entities: userLst); context.SaveChanges(); }