title: Testing crud operations in SQLite, using the repository pattern
body: <p>I m testing an app that my teacher made. I added the driver class, so every order has a driver associated with it, and a put the Driver as a foreign key in my Order class (So I have one to one relationship)</p>
  <pre><code> public class Order {
  
      [ForeignKey(&quot;Driver&quot;)]
      public int DriverId { get; set; }
      public int Id { get; set; }
      public List&lt;Item&gt; Items { get; set; }
  }
  
  public class Driver {
  
      public int ID { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }
  
      [Range(1, 5)]
      public int Rating { get; set; }
  }
  </code></pre>
  <p>Then I went ahead and created the add, update and delete driver, and did the migration and update to the database.</p>
  <p>Now I am tryin to test all this functionality, so  I made some unit-test but the only ones that are passing are Add_customner and Add_drver everything else fails</p>
  <p>So I am hoping to see if anyone can share some light</p>
  <p>This are my test</p>
  <pre><code>   [Test]
      public void AddCustomer_ValidCustomer_ReturnsTrue() {
          // Arrange
          Customer customer = new Customer() {
              Id = 1,
              FirstName = &quot;James&quot;,
              LastName = &quot;Cameron&quot;,
              StreetAddress = &quot;123 Sesame Street&quot;,
              City = &quot;New York City&quot;,
              ZIP = &quot;11111&quot;,
              State = &quot;NY&quot;,
              PhoneNumber = &quot;1111111111&quot;,
              Email = &quot;jc@terminator.com&quot;
  
          };
  
          // Act
  
          var result = uow.AddCustomer(customer);
  
          // Assert
  
          Assert.IsTrue(result);
  
          var qCust = _context.Customers.Where(q =&gt; q.Id == 1).FirstOrDefault();
          Assert.AreSame(qCust, customer);
  
  
      }
      [Test]
      public void AddDriver_ValidDriver_ReturnsTrue() {
          // Arrange
          Driver driver = new Driver() {
              ID = 1,
              FirstName = &quot;James&quot;,
              LastName = &quot;Cameron&quot;,
              Rating = 4
  
          };
  
          // Act
  
          var result = uow.AddDriver(driver);
  
          // Assert
  
          Assert.IsTrue(result);
  
          var qDrive = _context.Drivers.Where(q =&gt; q.ID == 1).FirstOrDefault();
          Assert.AreSame(qDrive, driver);
  
  
      }
      [Test]
      public void RemoveDriver_ValidDriver_ReturnsTrue() {
          // Arrange
          Driver driver = new Driver() {
              ID = 1,
              FirstName = &quot;James&quot;,
              LastName = &quot;Cameron&quot;,
              Rating = 4
  
          };
  
          // Act
  
          var result = uow.RemoveDriver(driver);
  
          // Assert
          var Drivera = _context.Drivers;
  
  
          Assert.IsTrue(result);
  
          var qDrive = _context.Drivers.Remove(driver);
          Assert.AreNotEqual(Drivera, qDrive);
  
  
      }
  
  
  
      [Test]
      public void UpdateDriver_ValidDriver_ReturnsTrue() {
          Driver driver = new Driver() {
              ID = 1,
              FirstName = &quot;James&quot;,
              LastName = &quot;Cameron&quot;,
              Rating = 4
          };
  
          var result = uow.UpdateDriver(driver);
  
          var qDrive = _context.Drivers.Where(q =&gt; q.ID == 1).FirstOrDefault();
          Assert.AreSame(qDrive, driver);
      }
  }
  </code></pre>
  <p>}</p>
  <p>For it to work it must return true</p>