Giter VIP home page Giter VIP logo

fluentassert's Issues

SObject Support

Consider:

  • isRecordType()
  • hasError()

Use SObject.get(String) to build something like

Fluent__Assert.that(sobject)
              .extracting("AccoutNumber, SomeOtherString__c")
              .containsExactly(new List<String>{'RealAccountNumber', 'Real Value of SOSc'}
              ...
              back()

Type-specific getters

Fluent__Assert.that(sobject)
              .getAsInteger(".....") // Returns IntegerAssertNavigator
              ...
              .back()

isRecordType in SObject behaves differently for default type and when a record type is set

Hi
I was trying to use isRecordType from SObject and I found this issue -

I created account like this -
Id customerRecTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Customer').getRecordTypeId();
Account acc = new Account(
Name = 'TEST ACCOUNT',
Source_ID__c = 'ACCOUNT 001',
recordTypeId = customerRecTypeId
);

insert ACC;

Fluent.Assert.that(acc).isRecordType('Customer') -> This fails
But
Fluent.Assert.that(acc).isRecordType(customerRecTypeId) -> This passes.

So it looks like if a record type is set during record creation then it compares against record type id not record type developer name.

I also looked into your code

global SObjectAssert isRecordType(String developerName) {
        notNull(actual, 'actual');
        notNull(developerName, 'developerName');

        **String actualRecordTypeDevName = actual.isSet('RecordTypeId') ? (String) actual.get('RecordTypeId') :** SObjectTypeUtil.getDefaultRecordTypeInfo(Schema.SObjectType.Account).getDeveloperName();
        assert(developerName == actualRecordTypeDevName, 'Expected RecordType to be \'{0}\' but found \'{0}\'', new List<Object> {developerName, actualRecordTypeDevName});

        return this;
    } 

It looks like if record type id is set then you are assigning that id to actualRecordTypeDevName . I was expecting you would fetch the developer name from that record type id and use that to compare the values.

Is this an expected behaviour ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.