Object Graph Comparison And Be Equivalent To | Unit Testing

Поделиться
HTML-код
  • Опубликовано: 8 янв 2025

Комментарии • 11

  • @haskell3702
    @haskell3702 Год назад

    How can I used BeEquivalentTo to compare ActualObject.Flied=null and ExpectedObject.Filed = String.Empty and get they are equivalent?

    • @themusingsofadev3565
      @themusingsofadev3565  Год назад

      They’re not equivalent. Null and empty string are different values in C#.
      The best you could do is tell fluent assertions to ignore that field.

    • @haskell3702
      @haskell3702 Год назад

      @@themusingsofadev3565 I can't ignore because I want to compare other values to be equals

    • @themusingsofadev3565
      @themusingsofadev3565  Год назад

      Then I would override the equals method on your class if possible, otherwise I think you’re out of luck. You could always ignore it on that test and then write a specific test for the empty string null problem

    • @haskell3702
      @haskell3702 Год назад

      @@themusingsofadev3565 I need a generic solution for every model that I read form a csv or xlsx, you know, string null becomes string empty in a file

    • @haskell3702
      @haskell3702 Год назад

      @@themusingsofadev3565now you understand?