Skip to content

Commit

Permalink
Issue #1 建立 Double 序列初始版本
Browse files Browse the repository at this point in the history
  • Loading branch information
mouson committed Jan 10, 2017
1 parent abd92ce commit f8ae307
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Helpers/SequenceCalculator/DoubleSequenceCalculator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Created by PhpStorm.
* User: mouson
* Date: 2017/1/10
* Time: 03:44
*/

namespace Mouson\Helpers\SequenceCalculator;

class DoubleSequenceCalculator implements CalculatorInterface
{

/**
* @param $value
*
* @return int|mixed
*/
public function calculate($value)
{
return ($value * 2);
}

public function getSequenceName()
{
return 'Double';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
namespace Mouson\Helpers\SequenceCalculator;

class DoubleSequenceCalculatorTest extends \PHPUnit_Framework_TestCase
{
public function test_物件產生後應可以取得物件名稱()
{
/** Arrange */
$target = new DoubleSequenceCalculator();

/** Assume */
$expected = 'Double';

/** Act */
$actual = $target->getSequenceName();

/** Assert */
$this->assertEquals($expected, $actual);
}

public function test_測試雙倍數列輸入0應回傳0()
{
/** Arrange */
$target = new DoubleSequenceCalculator();
$value = 0;
/** Assume */
$expected = 0;

/** Act */
$actual = $target->calculate($value);

/** Assert */
$this->assertEquals($expected, $actual);
}
}

0 comments on commit f8ae307

Please sign in to comment.