Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project sprint 5 #753

Open
wants to merge 29 commits into
base: project_sprint_3_start
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
faf59e2
работа над 4 спринтом
BlanxxtyIS Jul 6, 2023
a71ab4c
итог 4 спринта
BlanxxtyIS Jul 6, 2023
0b55fac
Исправлены ошибки
BlanxxtyIS Jul 9, 2023
dec2aa1
Merge pull request #1 from BlanxxtyIS/project_sprint_4
BlanxxtyIS Jul 9, 2023
bf3ea34
добавив шрифты в info.plst
BlanxxtyIS Jul 9, 2023
d5e7d4e
Merge pull request #2 from BlanxxtyIS/project_sprint_4
BlanxxtyIS Jul 9, 2023
048fefb
Исправления шрифтов
BlanxxtyIS Jul 10, 2023
0b27659
Merge pull request #3 from BlanxxtyIS/project_sprint_4
BlanxxtyIS Jul 10, 2023
f7b11a3
по рекомендациям наставника
BlanxxtyIS Jul 10, 2023
6c63a1e
Merge pull request #4 from BlanxxtyIS/project_sprint_5
BlanxxtyIS Jul 18, 2023
86e9aea
pull 5 sprint
BlanxxtyIS Jul 19, 2023
30ae4eb
закрыть 5 спринт
BlanxxtyIS Jul 26, 2023
00db49f
Merge pull request #6 from BlanxxtyIS/project_sprint_5
BlanxxtyIS Jul 26, 2023
6c523ae
готовый для сдачи на 6 спринт
BlanxxtyIS Aug 2, 2023
83a23b1
Merge pull request #8 from BlanxxtyIS/project_sprint_6
BlanxxtyIS Aug 8, 2023
1244f95
7 спринт старик
BlanxxtyIS Aug 8, 2023
8c8182d
7 спринтик
BlanxxtyIS Aug 8, 2023
e58e62b
Рефакторинг
BlanxxtyIS Aug 14, 2023
179704f
Рефакторинг. Продолжение
BlanxxtyIS Aug 14, 2023
5189e6a
Подготовка к сдаче на ревью
BlanxxtyIS Aug 14, 2023
1490d33
Сдача на ревью
BlanxxtyIS Aug 15, 2023
fbecd8d
Конечный вариант 7 спринт
BlanxxtyIS Aug 15, 2023
04ab200
Изменения по ревью 7 спринта
BlanxxtyIS Aug 17, 2023
569b051
перед исправлением
BlanxxtyIS Aug 18, 2023
5296089
сдать 7 спринт!!!!
BlanxxtyIS Aug 18, 2023
c7de73a
Исправления
BlanxxtyIS Aug 19, 2023
ca7edf3
на сдачу ревью 7 спринт
BlanxxtyIS Aug 20, 2023
2562d30
Merge pull request #9 from BlanxxtyIS/project_sprint_6
BlanxxtyIS Aug 21, 2023
d57340f
Merge pull request #7 from BlanxxtyIS/project_sprint_3_start
BlanxxtyIS Jun 7, 2024
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
30 changes: 30 additions & 0 deletions ArrayTests/ArrayTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// ArrayTests.swift
// ArrayTests
//
// Created by Марат Хасанов on 14.08.2023.
//

import XCTest
import Foundation

@testable import MovieQuiz

class ArrayTests: XCTestCase {
func testGetValueInRange() throws {
let array = [1, 1, 2, 3, 5]

let value = array[safe: 2]

XCTAssertNotNil(value)
XCTAssertEqual(value, 2)
}
func testGetValueOutOfRange() throws {

let array = [1, 1, 2, 3, 5]

let value = array[safe: 20]

XCTAssertNil(value)
}
}
31 changes: 31 additions & 0 deletions ArrayTests/MovieQuizPresenterTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// MovieQuizViewControllerMock.swift
// MovieQuizViewControllerMock
//
// Created by Марат Хасанов on 14.08.2023.
//

import XCTest
@testable import MovieQuiz

final class MovieQuizViewControllerMock: MovieQuizViewControllerProtocol {
func show(quiz step: QuizStepViewModel) {}
func show(quiz result: QuizResultsViewModel) {}
func highlightImageBorder(isCorrectAnswer: Bool) {}
func showLoadingIndicator() {}
func hideLoadingIndicator() {}
func showNetworkError(message: String) {}
}

final class MovieQuizPresenterTests: XCTestCase {
func testPresenterConvertModel() throws {
let viewControllerMock = MovieQuizViewControllerMock()
let sut = MovieQuizPresenter(viewController: viewControllerMock)
let emptyData = Data()
let question = QuizQuestion(image: emptyData, text: "Question Text", correctAnswer: true)
let viewModel = sut.convert(model: question)
XCTAssertNotNil(viewModel.image)
XCTAssertEqual(viewModel.question, "Question Text")
XCTAssertEqual(viewModel.questionNumber, "1/10")
}
}
50 changes: 50 additions & 0 deletions ArrayTests/MoviesLoaderTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// MoviesLoaderTests.swift
// MoviesLoaderTests
//
// Created by Марат Хасанов on 14.08.2023.
//

import XCTest

@testable import MovieQuiz

class MoviesLoaderTests: XCTestCase {
func testSuccessLoading() throws {

let stubNetworkClient = StubNetworkClient(emulateError: false)
let loader = MoviesLoader(networkClient: stubNetworkClient)

let expectation = expectation(description: "Loading expectation")

loader.loadMovies { result in
switch result {
case .success(let movies):
XCTAssertEqual(movies.items.count, 2)
expectation.fulfill()
case .failure(_):
XCTFail("Unexpected failure")
}
}
waitForExpectations(timeout: 1)
}

func testFailureLoading() throws {
let stubNetworkClient = StubNetworkClient(emulateError: true)
let loader = MoviesLoader(networkClient: stubNetworkClient)

let expectation = expectation(description: "Loading expectation")

loader.loadMovies { result in
switch result {
case .failure(let error):
XCTAssertNotNil(error)
expectation.fulfill()
case .success(_):
XCTFail("Unexpected failure")
}
}
waitForExpectations(timeout: 1)
}
}

366 changes: 363 additions & 3 deletions MovieQuiz.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion MovieQuiz/Helpers/UIColor+Extensions.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import UIKit

extension UIColor { }
extension UIColor {
static var ypGreen: UIColor { UIColor(named: "YP Green") ?? UIColor.green }
static var ypRed: UIColor { UIColor(named: "YP Red") ?? UIColor.red }
static var ypBlack: UIColor { UIColor(named: "YP Black") ?? UIColor.black }
static var ypBackground: UIColor { UIColor(named: "YP Background") ?? UIColor.darkGray }
static var ypGray: UIColor { UIColor(named: "YP Gray") ?? UIColor.gray }
static var ypWhite: UIColor { UIColor(named: "YP White") ?? UIColor.white }
}
16 changes: 16 additions & 0 deletions MovieQuiz/Models/AlertModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// AlertModel.swift
// MovieQuiz
//
// Created by Марат Хасанов on 19.07.2023.
//

import Foundation

struct AlertModel {
let title: String
let text: String
let buttonText: String
let alertId: String
let completion: () -> Void
}
22 changes: 22 additions & 0 deletions MovieQuiz/Models/GameRecord.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// GameRecord.swift
// MovieQuiz
//
// Created by Марат Хасанов on 19.07.2023.
//

import Foundation

struct GameRecord: Codable, Comparable {

//количество правильных ответов
let correct: Int
//количество вопросов квиза
let total: Int
let date: Date

// метод для сравнения счета на основе правильных ответов
static func < (lhs: GameRecord, rhs: GameRecord) -> Bool {
lhs.correct < rhs.correct
}
}
36 changes: 36 additions & 0 deletions MovieQuiz/Models/MostPopularMovies.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// MostPopularMovies.swift
// MovieQuiz
//
// Created by Марат Хасанов on 01.08.2023.
//

import Foundation

struct MostPopularMovies: Codable {
let errorMessage: String
let items: [MostPopularMovie]
}

struct MostPopularMovie: Codable {
let title: String
let rating: String
let imageURL: URL

var resizedImage: URL {
let urlString = imageURL.absoluteString

let imageURLString = urlString.components(separatedBy: "._")[0] + "._V0_UX600.jpg"

guard let newURL = URL(string: imageURLString) else {
return imageURL
}
return newURL
}

private enum CodingKeys: String, CodingKey {
case title = "fullTitle"
case rating = "imDbRating"
case imageURL = "image"
}
}
15 changes: 15 additions & 0 deletions MovieQuiz/Models/QuizQuestion.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// QuizQuestion.swift
// MovieQuiz
//
// Created by Марат Хасанов on 19.07.2023.
//

import Foundation

//Mock-данные
struct QuizQuestion {
let image: Data
let text: String
let correctAnswer: Bool
}
15 changes: 15 additions & 0 deletions MovieQuiz/Models/QuizResultsViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// QuizResultsViewModel.swift
// MovieQuiz
//
// Created by Марат Хасанов on 19.07.2023.
//

import Foundation

//Результат квиза
struct QuizResultsViewModel {
let title: String
let text: String
let buttonText: String
}
16 changes: 16 additions & 0 deletions MovieQuiz/Models/QuizStepViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// QuizStepViewModel.swift
// MovieQuiz
//
// Created by Марат Хасанов on 19.07.2023.
//

import Foundation
import UIKit

//Состояние "Вопрос показан
struct QuizStepViewModel {
let image: UIImage
let question: String
let questionNumber: String
}
Loading