コード例 #1
0
        public void ShouldReadBothUsersAndAttemptConnectionBetweenThemThenUpdateConector()
        {
            //GIVEN
            var connectionInProgress = Any.Instance <IConnectionInProgress>();
            var user1Id     = Any.String();
            var user2Id     = Any.String();
            var lookup      = Substitute.For <IUserLookup>();
            var destination = Substitute.For <IConnectorDestination>();
            var connector   = Substitute.For <IConnector>();
            var connectee   = Any.Instance <IConnectee>();
            var command     = new ConnectionUseCase(connectionInProgress, user1Id, user2Id, lookup, destination);

            lookup.LookupConnector(user1Id).Returns(connector);
            lookup.LookupConnectee(user2Id).Returns(connectee);

            //WHEN
            command.Execute();

            //THEN
            Received.InOrder(() =>
            {
                connector.AttemptConnectionWith(connectee, connectionInProgress);
                connector.WriteTo(destination);
            });
        }
コード例 #2
0
        public void ShouldReportInvalidOtherUserIdWhenInvalidConnecteeIdExceptionIsThrownFromLookup()
        {
            //GIVEN
            var connectionInProgress = Substitute.For <IConnectionInProgress>();
            var user1Id     = Any.String();
            var user2Id     = Any.String();
            var lookup      = Substitute.For <IUserLookup>();
            var destination = Substitute.For <IConnectorDestination>();
            var command     = new ConnectionUseCase(connectionInProgress, user1Id, user2Id, lookup, destination);

            lookup.LookupConnector(user1Id).Throws(Any.Instance <InvalidConnecteeIdException>());

            //WHEN
            command.Execute();

            //THEN
            XReceived.Only(() => connectionInProgress.Received(1).InvalidOtherUserId());
        }