Skip to content
Open
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
50e4182
workshop2
prepas May 2, 2018
0687034
change workshop #3
prepas May 9, 2018
f3221cf
03_armstrong_number
prepas May 10, 2018
d20ec51
added 04_roman_numerals task for workshop
Vv-git May 15, 2018
ab6da91
04_roman_numerals
prepas May 16, 2018
fb18071
04_roman_numerals
prepas May 16, 2018
b41c628
fix build
May 23, 2018
c7fe024
add bank ocr
May 23, 2018
429bf52
update readme
May 23, 2018
302c6c8
05_bank_ocr
May 23, 2018
3888d5a
05_bank_ocr
May 23, 2018
174d704
05_bank_ocr
May 23, 2018
8a26ae0
05bankocr_homework
May 23, 2018
9964bf7
05_word_wrapp
May 30, 2018
a19db22
added Allergies task description
driverdevteam May 31, 2018
655c03b
added 06_allergies homework
Vv-git May 31, 2018
dc1a3e2
modified description of 06_allergies homework
Vv-git May 31, 2018
1147cf4
Tests list
RSerhii Jun 3, 2018
f6ccd26
TEST CompareWithCorrectNumber RED
RSerhii Jun 3, 2018
45b3282
TEST CompareWithCorrectNumber GREEN
RSerhii Jun 3, 2018
f453d0a
TEST CompareWithIncorrectNumber RED
RSerhii Jun 3, 2018
f81d758
TEST CompareWithIncorrectNumber GREEN
RSerhii Jun 3, 2018
274accf
Updated tests list
RSerhii Jun 3, 2018
be06f41
TEST CompareWithCorrectNumber_4 RED
RSerhii Jun 3, 2018
4297715
TEST CompareWithCorrectNumber_4 GREEN
RSerhii Jun 3, 2018
b2f388d
TEST CompareWithComplexNumber_5 RED
RSerhii Jun 3, 2018
78a62dd
TEST CompareWithComplexNumber_5 GREEN
RSerhii Jun 3, 2018
a9f2b99
Refactoring removed unneeded test
RSerhii Jun 3, 2018
c11a883
Fixed compiler warnings
RSerhii Jun 3, 2018
17b00d0
TEST WithCorrectName RED
RSerhii Jun 3, 2018
5f2da8e
TEST WithCorrectName GREEN
RSerhii Jun 3, 2018
84c0e3a
TEST WithIncorrectName RED
RSerhii Jun 3, 2018
15eaa8c
TEST WithIncorrectName GREEN
RSerhii Jun 3, 2018
d784431
TEST WithCorrectName_tomatoes RED
RSerhii Jun 3, 2018
d717637
TEST WithCorrectName_tomatoes GREEN
RSerhii Jun 3, 2018
65c0cc6
TEST UnexistentAllergy_EmptyList RED
RSerhii Jun 3, 2018
e691094
TEST UnexistentAllergy_EmptyList GREEN
RSerhii Jun 3, 2018
957a4c1
TEST IsAllergicTo_UnexistentAllergy RED
RSerhii Jun 3, 2018
4aebc7b
TEST IsAllergicTo_UnexistentAllergy GREEN
RSerhii Jun 3, 2018
f5a572c
Refactoring
RSerhii Jun 3, 2018
48b6975
TEST List_OneAllergy RED
RSerhii Jun 3, 2018
dbf5782
TEST List_OneAllergy GREEN
RSerhii Jun 3, 2018
478ab67
Refactoring changed type of AllergiesList from vector to set
RSerhii Jun 3, 2018
7b67255
TEST List_TwoAllergy RED
RSerhii Jun 3, 2018
d4f0596
TEST List_TwoAllergy GREEN
RSerhii Jun 3, 2018
86eae8c
TEST IsAllergicTo_ExistentAllergy RED
RSerhii Jun 3, 2018
7b2492d
TEST IsAllergicTo_ExistentAllergy GREEN
RSerhii Jun 3, 2018
2d2e0a3
TEST IsAllergicTo_TwoAllergy GREEN
RSerhii Jun 3, 2018
4bc5acb
TEST List_ExistentAndUnexistentAllergy GREEN
RSerhii Jun 3, 2018
a5b2bad
Tests list
RSerhii Jun 9, 2018
fa4fc67
Added IFileSystem interface
RSerhii Jun 9, 2018
608fec2
Added const modifier
RSerhii Jun 9, 2018
de23466
Added MockFileSystem
RSerhii Jun 9, 2018
7344689
TEST Copy_NotExistentSrc RED
RSerhii Jun 9, 2018
2fc1fbe
refactoring
RSerhii Jun 9, 2018
634cd48
TEST Copy_GetFilesListEmpty RED
RSerhii Jun 9, 2018
fe8e917
TEST Copy_GetFilesListEmpty GREEN
RSerhii Jun 9, 2018
8867427
TEST ConcatPath_ConcatLeftWithRight RED
RSerhii Jun 9, 2018
905d480
TEST ConcatPath_ConcatLeftWithRight GREEN
RSerhii Jun 9, 2018
b582190
TEST ConcatLeftWithoutRight RED
RSerhii Jun 9, 2018
481060d
TEST ConcatLeftWithoutRight GREEN
RSerhii Jun 9, 2018
c21ef35
TEST ConcatPath_ConcatRightWithoutLeft RED
RSerhii Jun 9, 2018
7168f05
TEST ConcatPath_ConcatRightWithoutLeft GREEN
RSerhii Jun 9, 2018
7e3f122
TEST ConcatPath_ConcatEmpty GREEN
RSerhii Jun 9, 2018
0ef2433
refactoring
RSerhii Jun 9, 2018
b5c264f
TEST Copy_OneFile RED
RSerhii Jun 9, 2018
05ee56f
TEST Copy_OneFile GREEN (+fixed param order in test)
RSerhii Jun 9, 2018
e19f17e
TEST Copy_OneFile RED (added missing operation)
RSerhii Jun 9, 2018
bbdecf9
TEST Copy_OneFile GREEN (+fixed param in test)
RSerhii Jun 9, 2018
9b666c9
TEST Copy_TwoFiles RED
RSerhii Jun 9, 2018
b1b567f
TEST Copy_TwoFiles GREEN
RSerhii Jun 9, 2018
17b1d60
refactoring
RSerhii Jun 9, 2018
bdf6256
TEST Copy_FolderWithFile RED (+2 broken)
RSerhii Jun 10, 2018
bbb2c41
fixed broken tests
RSerhii Jun 10, 2018
f8e774e
TEST Copy_FolderWithFile GREEN
RSerhii Jun 10, 2018
a3595ab
refactoring
RSerhii Jun 10, 2018
59119f3
TEST Copy_FolderWithoutFiles GREEN
RSerhii Jun 10, 2018
abd98e1
refactoring
RSerhii Jun 10, 2018
787e8da
TEST Copy_FileAndFolderWithFile GREEN
RSerhii Jun 10, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 42 additions & 32 deletions tdd_intro/homework/07_filecopier/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ using FilesList = std::vector<std::string>;
const std::string s_srcFolder("C:\\Folder");
const std::string s_dstFolder("D:\\Folder");
const std::string s_fileName("file.name");
const std::string s_fileName1(s_fileName + "1");

std::string ConcatPath(const std::string& left, const std::string& right)
{
Expand All @@ -56,6 +57,11 @@ std::string ConcatPath(const std::string& left, const std::string& right)
return left + "\\" + right;
}

const std::string s_srcFilePath(ConcatPath(s_srcFolder, s_fileName));
const std::string s_dstFilePath(ConcatPath(s_dstFolder, s_fileName));
const std::string s_srcFilePath1(ConcatPath(s_srcFolder, s_fileName1));
const std::string s_dstFilePath1(ConcatPath(s_dstFolder, s_fileName1));

class IFileSystem
{
public:
Expand Down Expand Up @@ -118,6 +124,31 @@ class FileCopier : public IFileCopier
IFileSystem* m_fileSystem;
};

void CopyFileTest(const std::string& srcFolder,
const std::string& srcFilePath,
const std::string& fileName,
const std::string& dstFilePath,
MockFileSystem& fileSystem)
{
EXPECT_CALL(fileSystem, GetRelativePath(srcFilePath, srcFolder))
.WillOnce(testing::Return(fileName));
EXPECT_CALL(fileSystem, CopyFile(srcFilePath, dstFilePath))
.WillOnce(testing::Return(true));
}

void BeforeCopyFileTest(const std::string& srcFolder,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

название не очевидное

const std::string& dstFolder,
const FilesList& filesList,
MockFileSystem& fileSystem)
{
EXPECT_CALL(fileSystem, IsFileExist(srcFolder))
.WillOnce(testing::Return(true));
EXPECT_CALL(fileSystem, GetFilesList(srcFolder))
.WillOnce(testing::Return(filesList));
EXPECT_CALL(fileSystem, CreateDirectory(dstFolder))
.WillOnce(testing::Return(true));
}

TEST(FileCopierTests, Copy_NotExistentSrc)
{
MockFileSystem fileSystem;
Expand Down Expand Up @@ -149,19 +180,12 @@ TEST(FileCopierTests, Copy_OneFile)
MockFileSystem fileSystem;
testing::InSequence copySequence;

const std::string srcFilePath(ConcatPath(s_srcFolder, s_fileName));
const std::string dstFilePath(ConcatPath(s_dstFolder, s_fileName));
BeforeCopyFileTest(s_srcFolder,
s_dstFolder,
FilesList({s_srcFilePath}),
fileSystem);

EXPECT_CALL(fileSystem, IsFileExist(s_srcFolder))
.WillOnce(testing::Return(true));
EXPECT_CALL(fileSystem, GetFilesList(s_srcFolder))
.WillOnce(testing::Return(FilesList({srcFilePath})));
EXPECT_CALL(fileSystem, CreateDirectory(s_dstFolder))
.WillOnce(testing::Return(true));
EXPECT_CALL(fileSystem, GetRelativePath(srcFilePath, s_srcFolder))
.WillOnce(testing::Return(s_fileName));
EXPECT_CALL(fileSystem, CopyFile(srcFilePath, dstFilePath))
.WillOnce(testing::Return(true));
CopyFileTest(s_srcFolder, s_srcFilePath, s_fileName, s_dstFilePath, fileSystem);

FileCopier fileCopier(&fileSystem);
EXPECT_NO_THROW(fileCopier.Copy(s_srcFolder, s_dstFolder));
Expand All @@ -172,27 +196,13 @@ TEST(FileCopierTests, Copy_TwoFiles)
MockFileSystem fileSystem;
testing::InSequence copySequence;

const std::string srcFilePath(ConcatPath(s_srcFolder, s_fileName));
const std::string dstFilePath(ConcatPath(s_dstFolder, s_fileName));

const std::string fileName1(s_fileName+"1");
const std::string srcFilePath1(ConcatPath(s_srcFolder, fileName1));
const std::string dstFilePath1(ConcatPath(s_dstFolder, fileName1));
BeforeCopyFileTest(s_srcFolder,
s_dstFolder,
FilesList({s_srcFilePath, s_srcFilePath1}),
fileSystem);

EXPECT_CALL(fileSystem, IsFileExist(s_srcFolder))
.WillOnce(testing::Return(true));
EXPECT_CALL(fileSystem, GetFilesList(s_srcFolder))
.WillOnce(testing::Return(FilesList({srcFilePath, srcFilePath1})));
EXPECT_CALL(fileSystem, CreateDirectory(s_dstFolder))
.WillOnce(testing::Return(true));
EXPECT_CALL(fileSystem, GetRelativePath(srcFilePath, s_srcFolder))
.WillOnce(testing::Return(s_fileName));
EXPECT_CALL(fileSystem, CopyFile(srcFilePath, dstFilePath))
.WillOnce(testing::Return(true));
EXPECT_CALL(fileSystem, GetRelativePath(srcFilePath1, s_srcFolder))
.WillOnce(testing::Return(fileName1));
EXPECT_CALL(fileSystem, CopyFile(srcFilePath1, dstFilePath1))
.WillOnce(testing::Return(true));
CopyFileTest(s_srcFolder, s_srcFilePath, s_fileName, s_dstFilePath, fileSystem);
CopyFileTest(s_srcFolder, s_srcFilePath1, s_fileName1, s_dstFilePath1, fileSystem);

FileCopier fileCopier(&fileSystem);
EXPECT_NO_THROW(fileCopier.Copy(s_srcFolder, s_dstFolder));
Expand Down